Exemplo n.º 1
0
 def test_mdtol(self):
     na = np.nan
     array = np.array([[1., 2., 1., 2.], [1., 2., 3., na], [1., 2., na,
                                                            na]])
     array = as_lazy_data(array)
     var = STD_DEV.lazy_aggregate(array, axis=1, mdtol=0.3)
     masked_result = as_concrete_data(var, nans_replacement=np.ma.masked)
     masked_expected = np.ma.masked_array([0.57735, 1., 0.707107],
                                          mask=[0, 0, 1])
     self.assertMaskedArrayAlmostEqual(masked_result, masked_expected)
Exemplo n.º 2
0
 def test_mdtol(self):
     na = np.nan
     array = np.array([[1., 2., 1., 2.],
                       [1., 2., 3., na],
                       [1., 2., na, na]])
     array = as_lazy_data(array)
     var = STD_DEV.lazy_aggregate(array, axis=1, mdtol=0.3)
     masked_result = as_concrete_data(var, nans_replacement=np.ma.masked)
     masked_expected = np.ma.masked_array([0.57735, 1., 0.707107],
                                          mask=[0, 0, 1])
     self.assertMaskedArrayAlmostEqual(masked_result, masked_expected)
Exemplo n.º 3
0
 def test_mdtol(self):
     na = -999.888
     array = np.ma.masked_equal(
         [[1.0, 2.0, 1.0, 2.0], [1.0, 2.0, 3.0, na], [1.0, 2.0, na, na]], na
     )
     array = as_lazy_data(array)
     var = STD_DEV.lazy_aggregate(array, axis=1, mdtol=0.3)
     masked_result = as_concrete_data(var)
     masked_expected = np.ma.masked_array(
         [0.57735, 1.0, 0.707107], mask=[0, 0, 1]
     )
     self.assertMaskedArrayAlmostEqual(masked_result, masked_expected)
Exemplo n.º 4
0
 def test_ddof_zero(self):
     array = biggus.NumpyArrayAdapter(np.arange(8))
     var = STD_DEV.lazy_aggregate(array, axis=0, ddof=0)
     self.assertArrayAlmostEqual(var.ndarray(), np.array(2.291287))
Exemplo n.º 5
0
 def test_unsupported_mdtol(self):
     array = biggus.NumpyArrayAdapter(np.arange(8))
     msg = "unexpected keyword argument 'mdtol'"
     with self.assertRaisesRegexp(TypeError, msg):
         STD_DEV.lazy_aggregate(array, axis=0, mdtol=0.8)
Exemplo n.º 6
0
 def test_lazy_collapse(self):
     lazy_data = STD_DEV.lazy_aggregate(self.lazy_cube.lazy_data(), axis=0)
     self.assertArrayAlmostEqual(lazy_data.compute(), [1.58113883])
Exemplo n.º 7
0
 def test_lazy(self):
     lazy_data = STD_DEV.lazy_aggregate(self.lazy_cube.lazy_data(), axis=0)
     self.assertTrue(is_lazy_data(lazy_data))
Exemplo n.º 8
0
 def test_collapse(self):
     data = STD_DEV.aggregate(self.cube.data, axis=0)
     self.assertArrayAlmostEqual(data, [1.58113883])
Exemplo n.º 9
0
 def test_unsupported_mdtol(self):
     array = biggus.NumpyArrayAdapter(np.arange(8))
     msg = "unexpected keyword argument 'mdtol'"
     with self.assertRaisesRegexp(TypeError, msg):
         STD_DEV.lazy_aggregate(array, axis=0, mdtol=0.8)
Exemplo n.º 10
0
 def test(self):
     self.assertEqual(STD_DEV.name(), 'standard_deviation')
Exemplo n.º 11
0
 def test_lazy_collapse(self):
     lazy_data = STD_DEV.lazy_aggregate(self.lazy_cube.lazy_data(), axis=0)
     self.assertArrayAlmostEqual(lazy_data.compute(), [1.58113883])
Exemplo n.º 12
0
 def test_lazy(self):
     lazy_data = STD_DEV.lazy_aggregate(self.lazy_cube.lazy_data(), axis=0)
     self.assertTrue(is_lazy_data(lazy_data))
Exemplo n.º 13
0
 def test_collapse(self):
     data = STD_DEV.aggregate(self.cube.data, axis=0)
     self.assertArrayAlmostEqual(data, [1.58113883])
Exemplo n.º 14
0
 def test_name(self):
     self.assertEqual(STD_DEV.name(), 'standard_deviation')
Exemplo n.º 15
0
 def test_name(self):
     self.assertEqual(STD_DEV.name(), "standard_deviation")
Exemplo n.º 16
0
 def test_ddof_zero(self):
     array = biggus.NumpyArrayAdapter(np.arange(8))
     var = STD_DEV.lazy_aggregate(array, axis=0, ddof=0)
     self.assertArrayAlmostEqual(var.ndarray(), np.array(2.291287))
Exemplo n.º 17
0
 def test_ddof_zero(self):
     array = as_lazy_data(np.arange(8))
     var = STD_DEV.lazy_aggregate(array, axis=0, ddof=0)
     result = as_concrete_data(var)
     self.assertArrayAlmostEqual(result, np.array(2.291287))
Exemplo n.º 18
0
 def test_ddof_zero(self):
     array = as_lazy_data(np.arange(8))
     var = STD_DEV.lazy_aggregate(array, axis=0, ddof=0)
     result = as_concrete_data(var)
     self.assertArrayAlmostEqual(result, np.array(2.291287))
Exemplo n.º 19
0
 def test(self):
     shape = ()
     kwargs = dict()
     self.assertTupleEqual(STD_DEV.aggregate_shape(**kwargs), shape)
     kwargs = dict(forfar=5, fife=4)
     self.assertTupleEqual(STD_DEV.aggregate_shape(**kwargs), shape)
Exemplo n.º 20
0
 def test(self):
     shape = ()
     kwargs = dict()
     self.assertTupleEqual(STD_DEV.aggregate_shape(**kwargs), shape)
     kwargs = dict(forfar=5, fife=4)
     self.assertTupleEqual(STD_DEV.aggregate_shape(**kwargs), shape)