Exemplo n.º 1
0
 def test_3d(self):
     "Tests median w/ 3D"
     x = maskedarray.arange(24).reshape(3,4,2)
     x[x%3==0] = masked
     assert_equal(mmedian(x,0), [[12,9],[6,15],[12,9],[18,15]])
     x.shape = (4,3,2)
     assert_equal(mmedian(x,0),[[99,10],[11,99],[13,14]])
     x = maskedarray.arange(24).reshape(4,3,2)
     x[x%5==0] = masked
     assert_equal(mmedian(x,0), [[12,10],[8,9],[16,17]])
Exemplo n.º 2
0
    def _test_verify_write_range_cser(self):
        "verify that _test_write_range_write_cser worked as expected"

        ser = self.db.read('$rangeCSer')
        result = ma.arange(9).astype(np.float32)
        result[:4] = ma.masked

        assert_array_equal(ser, result)
Exemplo n.º 3
0
 def test_trim(self):
     "Tests trimming."
     x = maskedarray.arange(100)
     assert_equal(trim_both(x).count(), 60)
     assert_equal(trim_tail(x,tail='r').count(), 80)
     x[50:70] = masked
     trimx = trim_both(x)
     assert_equal(trimx.count(), 48)
     assert_equal(trimx._mask, [1]*16 + [0]*34 + [1]*20 + [0]*14 + [1]*16)
     x._mask = nomask
     x.shape = (10,10)
     assert_equal(trim_both(x).count(), 60)
     assert_equal(trim_tail(x).count(), 80)
Exemplo n.º 4
0
 def __init__(self, *args, **kwds):
     NumpyTestCase.__init__(self, *args, **kwds)
     self.a = maskedarray.arange(1,101)
Exemplo n.º 5
0
    else:
        fig = tsfigure(series=series)
    # Get the current axe, or create one
    sub = fig._axstack()
    if sub is None:
        sub = fig.add_tsplot(111,series=series,**kwargs)
    try:
        ret = sub.tsplot(series, *args, **kwargs)
        pylab.draw_if_interactive()
    except:
        pylab.hold(b)
        raise
    pylab.hold(b)
    return ret

################################################################################
if __name__ == '__main__':

    da = date_array(start_date=Date(freq='B', year=2003, quarter=3, month=1, day=17),
                    length=10)
    ser = timeseries.time_series(MA.arange(len(da)), dates=da)
#    ser[4] = MA.masked
#    ser_2 = timeseries.time_series(MA.arange(len(da)), dates=da.asfreq('Q'))

    pylab.figure()
    pylab.gcf().add_tsplot(111)
    pylab.gca().tsplot(ser, 'ko-')
    pylab.gca().format_dateaxis()
#    pylab.gca().tsplot(ser_2, 'rs')
    pylab.show()