Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #4
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))
Beispiel #5
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))
Beispiel #6
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)
Beispiel #7
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])
Beispiel #8
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))
Beispiel #9
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))
Beispiel #10
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])
Beispiel #11
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))
Beispiel #12
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))
Beispiel #13
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)