Пример #1
0
 def test_apply_on_fields_scalar(self):
     "Test apply_on_fields : scalar output"
     adtype = [('fi', int), ('ff', float)]
     a = np.array([(1, 1.), (2, 2.), (3, 3.)], dtype=adtype)
     func = ma.sum
     test = apply_on_fields(a, func)
     control = np.array([(6, 6.)], dtype=adtype)
     assert_equal(test, control)
 def test_apply_on_fields_scalar(self):
     "Test apply_on_fields : scalar output"
     adtype = [('fi', int), ('ff', float)]
     a = np.array([(1, 1.), (2, 2.), (3, 3.)], dtype=adtype)
     func = ma.sum
     test = apply_on_fields(a, func)
     control = np.array([(6, 6.)], dtype=adtype)
     assert_equal(test, control)
Пример #3
0
 def test_apply_on_fields_scalar_wmask(self):
     "Test apply_on_fields scalar output w/ mask"
     adtype = [('fi', int), ('ff', float)]
     a = ma.array([(1, 1.), (2, 2.), (3, 3.)],
                  mask=[(0, 1), (0, 1), (0, 1)],
                  dtype=adtype)
     func = ma.sum
     test = apply_on_fields(a, func)
     control = ma.array((6, 6.), mask=(0, 1), dtype=adtype)
     assert_equal(test, control)
 def test_apply_on_fields_scalar_wmask(self):
     "Test apply_on_fields scalar output w/ mask"
     adtype = [('fi', int), ('ff', float)]
     a = ma.array([(1, 1.), (2, 2.), (3, 3.)],
                  mask=[(0, 1), (0, 1), (0, 1)],
                  dtype=adtype)
     func = ma.sum
     test = apply_on_fields(a, func)
     control = ma.array((6, 6.), mask=(0, 1), dtype=adtype)
     assert_equal(test, control)
Пример #5
0
 def test_apply_on_fields_array(self):
     "Test apply_on_fields: array output"
     adtype = [('fi', int), ('ff', float)]
     a = ma.array([(1, 1.), (2, 2.), (3, 3.)],
                  mask=[(0, 0), (0, 1), (0, 0)],
                  dtype=adtype)
     func = ma.cumsum
     test = apply_on_fields(a, func)
     control = ma.array([(1, 1.), (3, -1), (6, 4.)],
                        mask=[(0, 0), (0, 1), (0, 0)],
                        dtype=adtype)
     assert_equal(test, control)
 def test_apply_on_fields_array(self):
     "Test apply_on_fields: array output"
     adtype = [('fi', int), ('ff', float)]
     a = ma.array([(1, 1.), (2, 2.), (3, 3.)],
                  mask=[(0, 0), (0, 1), (0, 0)],
                  dtype=adtype)
     func = ma.cumsum
     test = apply_on_fields(a, func)
     control = ma.array([(1, 1.), (3, -1), (6, 4.)],
                        mask=[(0, 0), (0, 1), (0, 0)],
                        dtype=adtype)
     assert_equal(test, control)
Пример #7
0
 def test_apply_on_fields_series(self):
     "Test apply_on_fields w/ time_series"
     adtype = [('fi', int), ('ff', float)]
     a = ts.time_series([(1, 1.), (2, 2.), (3, 3.)],
                        mask=[(0, 0), (0, 1), (0, 0)],
                        dtype=adtype,
                        start_date=ts.now('M'))
     func = ma.cumsum
     test = apply_on_fields(a, func)
     control = ts.time_series([(1, 1.), (3, -1), (6, 4.)],
                              mask=[(0, 0), (0, 1), (0, 0)],
                              dtype=adtype,
                              start_date=ts.now('M'))
     assert_equal(test, control)
     self.failUnless(isinstance(test, ts.TimeSeries))
     assert_equal(test.dates, control.dates)
 def test_apply_on_fields_series(self):
     "Test apply_on_fields w/ time_series"
     adtype = [('fi', int), ('ff', float)]
     a = ts.time_series([(1, 1.), (2, 2.), (3, 3.)],
                        mask=[(0, 0), (0, 1), (0, 0)],
                        dtype=adtype,
                        start_date=ts.now('M'))
     func = ma.cumsum
     test = apply_on_fields(a, func)
     control = ts.time_series([(1, 1.), (3, -1), (6, 4.)],
                              mask=[(0, 0), (0, 1), (0, 0)],
                              dtype=adtype,
                              start_date=ts.now('M'))
     assert_equal(test, control)
     self.failUnless(isinstance(test, ts.TimeSeries))
     assert_equal(test.dates, control.dates)