示例#1
0
    def test_projection_with_groups(self):
        calc_projected = projection(self.x, self.groups, axis=0)
        exp_projected = pd.DataFrame(self.x).groupby(
            self.groups
        ).transform(lambda s: s / np.sqrt(np.square(s).sum(axis=0)))

        np.testing.assert_array_almost_equal(calc_projected, exp_projected)
示例#2
0
    def test_projection(self):
        calc_projected = projection(self.x)
        exp_projected = self.x / np.sqrt(
            np.sum(np.square(self.x), axis=1).reshape((-1, 1)))

        np.testing.assert_array_almost_equal(calc_projected, exp_projected)