Esempio n. 1
0
    def test_dataframe(self):
        x = DataFrame(randn(2, 3))

        for axis, ddof in self.args:
            s = sem(x, axis, ddof)
            self.assert_(np.issubdtype(s.dtype, np.floating))
            self.assertIsInstance(s, (Series, np.ndarray))
Esempio n. 2
0
    def test_panel(self):
        x = Panel(randn(4, 3, 2))
        axes = self.axes + (2,)
        args = itools.product(axes, self.ddof)

        for axis, ddof in args:
            s = sem(x, axis, ddof)
            self.assertIsInstance(s, DataFrame)
Esempio n. 3
0
    def test_1d(self):
        x = randn(2)

        for axis, ddof in self.args:
            if axis == 1:
                self.assertRaises(IndexError, sem, x, axis, ddof)
            else:
                s = sem(x, axis, ddof)
                dtype = s.dtype
                self.assert_(np.issubdtype(dtype, np.floating))
Esempio n. 4
0
    def test_series(self):
        x = Series(randn(13))

        for axis, ddof in self.args:

            if axis == 1:
                self.assertRaises(IndexError, sem, x, axis, ddof)
            else:
                s = sem(x, axis, ddof)

                try:
                    dtype = s.dtype
                    self.assert_(np.issubdtype(dtype, np.floating))
                except AttributeError:
                    dtype = type(s)
                    self.assertIsInstance(s, (np.floating, float))
Esempio n. 5
0
    def test_2d(self):
        x = randn(3, 2)

        for axis, ddof in self.args:
            s = sem(x, axis, ddof)

            try:
                dtype = s.dtype
            except AttributeError:
                dtype = type(s)

            sshape = list(s.shape)
            not_xshape = list(filter(lambda a: a != x.shape[axis], x.shape))
            self.assertListEqual(not_xshape, sshape)
            self.assert_(np.issubdtype(dtype, np.floating))
            self.assertIsInstance(s, np.ndarray)
Esempio n. 6
0
    def test_3d(self):
        x = randn(4, 3, 2)
        axes = self.axes + (2,)
        args = itools.product(axes, self.ddof)

        for axis, ddof in args:
            s = sem(x, axis, ddof)

            try:
                dtype = s.dtype
            except AttributeError:
                dtype = type(s)

            self.assert_(np.issubdtype(dtype, np.floating))
            sshape = list(s.shape)
            not_xshape = list(filter(lambda a: a != x.shape[axis], x.shape))
            self.assertListEqual(not_xshape, sshape)
            self.assertIsInstance(s, np.ndarray)
Esempio n. 7
0
 def test_0d(self):
     x = randn()
     for axis, ddof in self.args:
         s = sem(x, axis, ddof)
         self.assertEqual(s, 0.0)