def test_ediff1d_toend(self):
     # Test ediff1d w/ to_end
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     test = ediff1d(x, to_end=masked)
     control = array([1, 1, 1, 4, 0], mask=[1, 0, 0, 1, 1])
     assert_equal(test, control)
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
     #
     test = ediff1d(x, to_end=[1, 2, 3])
     control = array([1, 1, 1, 4, 1, 2, 3], mask=[1, 0, 0, 1, 0, 0, 0])
     assert_equal(test, control)
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
 def test_ediff1d_tobegin(self):
     # Test ediff1d w/ to_begin
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     test = ediff1d(x, to_begin=masked)
     control = array([0, 1, 1, 1, 4], mask=[1, 1, 0, 0, 1])
     assert_equal(test, control)
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
     #
     test = ediff1d(x, to_begin=[1, 2, 3])
     control = array([1, 2, 3, 1, 1, 1, 4], mask=[0, 0, 0, 1, 0, 0, 1])
     assert_equal(test, control)
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
Exemple #3
0
 def test_ediff1d_toend(self):
     # Test ediff1d w/ to_end
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     test = ediff1d(x, to_end=masked)
     control = array([1, 1, 1, 4, 0], mask=[1, 0, 0, 1, 1])
     assert_equal(test, control)
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
     #
     test = ediff1d(x, to_end=[1, 2, 3])
     control = array([1, 1, 1, 4, 1, 2, 3], mask=[1, 0, 0, 1, 0, 0, 0])
     assert_equal(test, control)
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
Exemple #4
0
 def test_ediff1d_tobegin(self):
     # Test ediff1d w/ to_begin
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     test = ediff1d(x, to_begin=masked)
     control = array([0, 1, 1, 1, 4], mask=[1, 1, 0, 0, 1])
     assert_equal(test, control)
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
     #
     test = ediff1d(x, to_begin=[1, 2, 3])
     control = array([1, 2, 3, 1, 1, 1, 4], mask=[0, 0, 0, 1, 0, 0, 1])
     assert_equal(test, control)
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
Exemple #5
0
 def test_ediff1d_tobegin_toend(self):
     # Test ediff1d w/ to_begin and to_end
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     test = ediff1d(x, to_end=masked, to_begin=masked)
     control = array([0, 1, 1, 1, 4, 0], mask=[1, 1, 0, 0, 1, 1])
     assert_equal(test, control)
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
     #
     test = ediff1d(x, to_end=[1, 2, 3], to_begin=masked)
     control = array([0, 1, 1, 1, 4, 1, 2, 3], mask=[1, 1, 0, 0, 1, 0, 0, 0])
     assert_equal(test, control)
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
 def test_ediff1d_ndarray(self):
     # Test ediff1d w/ a ndarray
     x = np.arange(5)
     test = ediff1d(x)
     control = array([1, 1, 1, 1], mask=[0, 0, 0, 0])
     assert_equal(test, control)
     self.assertTrue(isinstance(test, MaskedArray))
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
     #
     test = ediff1d(x, to_end=masked, to_begin=masked)
     control = array([0, 1, 1, 1, 1, 0], mask=[1, 0, 0, 0, 0, 1])
     self.assertTrue(isinstance(test, MaskedArray))
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
Exemple #7
0
 def test_ediff1d_ndarray(self):
     # Test ediff1d w/ a ndarray
     x = np.arange(5)
     test = ediff1d(x)
     control = array([1, 1, 1, 1], mask=[0, 0, 0, 0])
     assert_equal(test, control)
     self.assertTrue(isinstance(test, MaskedArray))
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
     #
     test = ediff1d(x, to_end=masked, to_begin=masked)
     control = array([0, 1, 1, 1, 1, 0], mask=[1, 0, 0, 0, 0, 1])
     self.assertTrue(isinstance(test, MaskedArray))
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
Exemple #8
0
 def test_ediff1d_tobegin_toend(self):
     # Test ediff1d w/ to_begin and to_end
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     test = ediff1d(x, to_end=masked, to_begin=masked)
     control = array([0, 1, 1, 1, 4, 0], mask=[1, 1, 0, 0, 1, 1])
     assert_equal(test, control)
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
     #
     test = ediff1d(x, to_end=[1, 2, 3], to_begin=masked)
     control = array([0, 1, 1, 1, 4, 1, 2, 3],
                     mask=[1, 1, 0, 0, 1, 0, 0, 0])
     assert_equal(test, control)
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
 def test_ediff1d(self):
     # Tests mediff1d
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     control = array([1, 1, 1, 4], mask=[1, 0, 0, 1])
     test = ediff1d(x)
     assert_equal(test, control)
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)
Exemple #10
0
 def test_ediff1d(self):
     # Tests mediff1d
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     control = array([1, 1, 1, 4], mask=[1, 0, 0, 1])
     test = ediff1d(x)
     assert_equal(test, control)
     assert_equal(test.filled(0), control.filled(0))
     assert_equal(test.mask, control.mask)
Exemple #11
0
 def test_ediff1d(self):
     "Tests mediff1d"
     x = masked_array(np.arange(5), mask=[1, 0, 0, 0, 1])
     control = array([1, 1, 1, 4], mask=[1, 0, 0, 1])
     test = ediff1d(x)
     assert_equal(test, control)
     assert_equal(test.data, control.data)
     assert_equal(test.mask, control.mask)