コード例 #1
0
def test_get_cdelt_pa2():
    cdelt = (-1.5, 3)
    pa = -25.
    header = create_fitsheader((10, 10), cdelt=cdelt, pa=pa)
    cdelt_, pa_ = get_cdelt_pa(header)
    assert_eq(cdelt, cdelt_)
    assert_eq(pa, pa_)
コード例 #2
0
ファイル: test_ufuncs.py プロジェクト: ghisvail/pyoperators
 def func(a, mask):
     actual = masking(a, mask)
     expected = a.copy()
     expected[mask] = 0
     assert_eq(actual, expected)
     masking(a, mask, a)
     assert_eq(a, expected)
コード例 #3
0
ファイル: test_linear.py プロジェクト: ghisvail/pyoperators
def test_sum_operator():
    for s in SHAPES[1:]:
        for a in [None] + list(range(len(s))):
            op = SumOperator(axis=a)
            d = op.todense(shapein=s)
            t = op.T.todense(shapeout=s)
            assert_eq(d, t.T)
コード例 #4
0
ファイル: test_ufuncs.py プロジェクト: ghisvail/pyoperators
 def func(x1, x2, cdtype):
     result = multiply_conjugate(x1, x2)
     expected = x1 * x2.conjugate()
     assert_eq(result, expected)
     result[...] = 0
     multiply_conjugate(x1, x2, result)
     assert_eq(result, expected)
コード例 #5
0
 def f(cls, func, axis, m):
     keywords_array = {'unit': 'u'}
     if cls is Tod:
         keywords_array['mask'] = m
     array = cls(data, **keywords_array)
     keywords_func = {'axis': axis} if func is not np.round else {}
     result = func(array, **keywords_func)
     if cls is Tod:
         ref = func(np.ma.MaskedArray(array.magnitude, mask=m),
                    **keywords_func)
         if not isinstance(ref, np.ndarray):
             ref = np.ma.MaskedArray(ref)
     else:
         ref = func(array.magnitude, **keywords_func)
     assert_equal(result.view(np.ndarray), ref)
     if np.isscalar(result):
         return
     if func is np.var:
         assert result._unit == {'u': 2}
     else:
         assert result._unit == {'u': 1}
     if cls is Map:
         assert_is_none(result.coverage)
         assert_is_none(result.error)
     elif cls is Tod:
         if result.mask is None:
             assert not ref.mask
         else:
             assert_eq(result.mask, ref.mask)
コード例 #6
0
 def func(shape, dtype):
     d = MPIDistributionGlobalOperator(shape)
     x_global = np.ones(shape, dtype)
     s = split(shape[0], size, rank)
     x_local = d(x_global)
     assert_eq(x_local, x_global[s])
     assert_eq(d.T(x_local), x_global)
コード例 #7
0
def test_sum_operator():
    for s in SHAPES[1:]:
        for a in [None] + list(range(len(s))):
            op = SumOperator(axis=a)
            d = op.todense(shapein=s)
            t = op.T.todense(shapeout=s)
            assert_eq(d, t.T)
コード例 #8
0
 def f(cls, func, axis, m):
     keywords_array = {'unit': 'u'}
     if cls is Tod:
         keywords_array['mask'] = m
     array = cls(data, **keywords_array)
     keywords_func = {'axis': axis} if func is not np.round else {}
     result = func(array, **keywords_func)
     if cls is Tod:
         ref = func(np.ma.MaskedArray(array.magnitude, mask=m),
                    **keywords_func)
         if not isinstance(ref, np.ndarray):
             ref = np.ma.MaskedArray(ref)
     else:
         ref = func(array.magnitude, **keywords_func)
     assert_equal(result.view(np.ndarray), ref)
     if np.isscalar(result):
         return
     if func is np.var:
         assert result._unit == {'u': 2}
     else:
         assert result._unit == {'u': 1}
     if cls is Map:
         assert_is_none(result.coverage)
         assert_is_none(result.error)
     elif cls is Tod:
         if result.mask is None:
             assert not ref.mask
         else:
             assert_eq(result.mask, ref.mask)
コード例 #9
0
ファイル: test_mpi.py プロジェクト: ghisvail/pyoperators
 def func(shape, dtype):
     d = MPIDistributionGlobalOperator(shape)
     x_global = np.ones(shape, dtype)
     s = split(shape[0], size, rank)
     x_local = d(x_global)
     assert_eq(x_local, x_global[s])
     assert_eq(d.T(x_local), x_global)
コード例 #10
0
ファイル: test_madmap1.py プロジェクト: pchanial/pysimulators
def test_endian():
    bendian = _read_filters(path + 'invntt_be', bigendian=True)
    lendian = _read_filters(path + 'invntt_le')
    assert len(bendian) == 6
    assert bendian[0]['data'].size == 101
    assert_same(bendian[0]['data'][0], 5597147.4155586753)
    assert_eq(lendian, bendian)
コード例 #11
0
    def func(shape, axis):
        dX = DifferenceOperator(axis=axis, shapein=shape)
        a = np.arange(product(shape)).reshape(shape)
        assert_eq(dX(a), np.diff(a, axis=axis))
        dX_dense = dX.todense()

        dXT_dense = dX.T.todense()
        assert_eq(dX_dense.T, dXT_dense)
コード例 #12
0
ファイル: test_utils.py プロジェクト: pchanial/pyoperators
 def func(n, m):
     slices = split(n, m)
     assert_eq(len(slices), m)
     x = np.zeros(n, int)
     for s in slices:
         x[s] += 1
     assert_same(x, 1, broadcasting=True)
     assert_eq([split(n, m, i) for i in range(m)], slices)
コード例 #13
0
ファイル: test_linear.py プロジェクト: ghisvail/pyoperators
    def func(shape, axis):
        dX = DifferenceOperator(axis=axis, shapein=shape)
        a = np.arange(product(shape)).reshape(shape)
        assert_eq(dX(a), np.diff(a, axis=axis))
        dX_dense = dX.todense()

        dXT_dense = dX.T.todense()
        assert_eq(dX_dense.T, dXT_dense)
コード例 #14
0
ファイル: test_utils.py プロジェクト: satorchi/pyoperators
 def func(n, m):
     slices = split(n, m)
     assert_eq(len(slices), m)
     x = np.zeros(n, int)
     for s in slices:
         x[s] += 1
     assert_same(x, 1, broadcasting=True)
     assert_eq([split(n, m, i) for i in range(m)], slices)
コード例 #15
0
 def func(c, o, r):
     op = MultiplicationOperator([c, o])
     assert_eq(op(v), c.data*o(v))
     assert_is_type(op, r[0])
     if type(op) is CompositionOperator:
         op = op.operands[0]
         r = r[1]
         assert_is_type(op, r[0])
     assert_eq, op.data, r[1]
コード例 #16
0
    def func(opout, opin, idin):
        if opin is not None and idin is not None and opin != idin:
            return
        p = Op(shapeout=opout, shapein=opin) * IdentityOperator(shapein=idin)

        if idin is None:
            idin = opin
        assert_is_instance(p, Op)
        assert_eq(p.shapein, idin)
        assert_eq(p.shapeout, opout)
コード例 #17
0
ファイル: test_fft.py プロジェクト: ghisvail/pyoperators
 def func(k1, k2):
     c1 = ConvolutionOperator(k1, shape)
     c2 = ConvolutionOperator(k2, shape)
     c = c1 * c2
     if k1.dtype.kind == 'f' and k2.dtype.kind == 'f':
         assert_is_instance(c, _FFTWRealConvolutionOperator)
     else:
         assert_is_instance(c, CompositionOperator)
         assert_eq(len(c.operands), 3)
     assert np.allclose(c(image.real), ref)
コード例 #18
0
def test_wcsoperator_kapteyn():
    from pysimulators.wcsutils import WCSKapteynToWorldOperator
    path = os.path.join(os.path.dirname(__file__), 'data/header_gnomonic.fits')
    header = pyfits.open(path)[0].header

    toworld_kapteyn = WCSKapteynToWorldOperator(header)
    crpix = (header['CRPIX1'], header['CRPIX2'])
    crval = (header['CRVAL1'], header['CRVAL2'])
    assert_eq(toworld_kapteyn(crpix), crval)
    assert_eq(toworld_kapteyn.I(crval), crpix)
コード例 #19
0
ファイル: test_linear.py プロジェクト: ghisvail/pyoperators
def test_diagonal_numexpr2():
    d1 = DiagonalNumexprOperator([1, 2, 3], '(data+1)*3',
                                 broadcast='rightward')
    d2 = DiagonalNumexprOperator([3, 2, 1], '(data+2)*2')
    d = d1 * d2
    assert_is_instance(d, DiagonalOperator)
    assert_eq(d.broadcast, 'disabled')
    assert_eq(d.data, [60, 72, 72])
    c = BlockColumnOperator(3*[IdentityOutplaceOperator()], new_axisout=0)
    v = [1, 2]
    assert_inplace_outplace(d1*c, v, d1(c(v)))
コード例 #20
0
def test_diagonal_numexpr2():
    d1 = DiagonalNumexprOperator([1, 2, 3],
                                 '(data+1)*3',
                                 broadcast='rightward')
    d2 = DiagonalNumexprOperator([3, 2, 1], '(data+2)*2')
    d = d1 * d2
    assert_is_instance(d, DiagonalOperator)
    assert_eq(d.broadcast, 'disabled')
    assert_eq(d.data, [60, 72, 72])
    c = BlockColumnOperator(3 * [IdentityOutplaceOperator()], new_axisout=0)
    v = [1, 2]
    assert_inplace_outplace(d1 * c, v, d1(c(v)))
コード例 #21
0
 def func(broadcast, values):
     if broadcast == 'rightward':
         expected = (values.T * (diag.T + 1) * 3).T
     else:
         expected = values * (diag + 1) * 3
     op = DiagonalNumexprOperator(diag, expr, broadcast=broadcast)
     if broadcast in ('leftward', 'rightward'):
         assert op.broadcast == broadcast
         assert_is_none(op.shapein)
     else:
         assert op.broadcast == 'disabled'
         assert_eq(op.shapein, diag.shape)
         assert_eq(op.shapeout, diag.shape)
     assert_inplace_outplace(op, values, expected)
コード例 #22
0
ファイル: test_linear.py プロジェクト: ghisvail/pyoperators
 def func(broadcast, values):
     if broadcast == 'rightward':
         expected = (values.T*(diag.T+1)*3).T
     else:
         expected = values*(diag+1)*3
     op = DiagonalNumexprOperator(diag, expr, broadcast=broadcast)
     if broadcast in ('leftward', 'rightward'):
         assert op.broadcast == broadcast
         assert_is_none(op.shapein)
     else:
         assert op.broadcast == 'disabled'
         assert_eq(op.shapein, diag.shape)
         assert_eq(op.shapeout, diag.shape)
     assert_inplace_outplace(op, values, expected)
コード例 #23
0
def test1():
    # creation of the sky map
    msize = 50
    mymap = gaussian(2*(msize*2+1,), 10, unit='Jy/pixel')
    cd = np.array([[-1., 0.],[0., 1.]]) / 3600.
    header = create_fitsheader(fromdata=mymap, crval=[53.,27.], cd=cd)
    mymap.header = header

    # creation of the simulation
    scan = PacsObservation.create_scan((header['CRVAL1'], header['CRVAL2']),
               instrument_angle=0., length=60, nlegs=1, angle=20.)
    simul = PacsSimulation(scan, 'red', policy_bad_detector='keep',
                           policy_other='keep')

    # build the acquisition model
    model = CompressionAverageOperator(simul.slice.compression_factor) * \
            simul.get_projection_operator(header=header, npixels_per_sample=49)

    # get the noiseless tod
    tod = model(mymap)

    filename = 'simul-'+str(uuid1())+'.fits'

    try:
        simul.save(filename, tod)
        simul2 = PacsObservation(filename, policy_bad_detector='keep',
                                 policy_other='keep')
        status2 = simul2.status
        tod2 = simul2.get_tod()
    finally:
        try:
            os.remove(filename)
        except:
            pass

    for field in simul.status.dtype.names:
        if field == 'BAND': continue
        assert_eq(simul.status[field], status2[field])

    assert_eq(tod, tod2)
    fields = [x for x in simul.slice.dtype.names if x not in ('filename','unit')]
    for field in fields:
        if getattr(simul.slice[0], field) != getattr(simul2.slice[0], field):
            msg = "Field '" + field + "'"
            if field == 'scan_step':
                print(msg + ' not implemented.')
            else:
                assert False
コード例 #24
0
def test_block_column2():
    p = np.matrix([[1, 0], [0, 2], [1, 0]])
    o = asoperator(np.matrix(p))
    e = BlockColumnOperator([o, 2*o], axisout=0)
    assert_eq(e.todense(), np.vstack([p, 2*p]))
    assert_eq(e.T.todense(), e.todense().T)
    e = BlockColumnOperator([o, 2*o], new_axisout=0)
    assert_eq(e.todense(), np.vstack([p, 2*p]))
    assert_eq(e.T.todense(), e.todense().T)
コード例 #25
0
def test_block_row2():
    p = np.matrix([[1, 0], [0, 2], [1, 0]])
    o = asoperator(np.matrix(p))
    r = BlockRowOperator([o, 2 * o], axisin=0)
    assert_eq(r.todense(), np.hstack([p, 2 * p]))
    assert_eq(r.T.todense(), r.todense().T)
    r = BlockRowOperator([o, 2 * o], new_axisin=0)
    assert_eq(r.todense(), np.hstack([p, 2 * p]))
    assert_eq(r.T.todense(), r.todense().T)
コード例 #26
0
def test_block_column2():
    p = np.matrix([[1, 0], [0, 2], [1, 0]])
    o = asoperator(np.matrix(p))
    e = BlockColumnOperator([o, 2 * o], axisout=0)
    assert_eq(e.todense(), np.vstack([p, 2 * p]))
    assert_eq(e.T.todense(), e.todense().T)
    e = BlockColumnOperator([o, 2 * o], new_axisout=0)
    assert_eq(e.todense(), np.vstack([p, 2 * p]))
    assert_eq(e.T.todense(), e.todense().T)
コード例 #27
0
def test_block_row2():
    p = np.matrix([[1, 0], [0, 2], [1, 0]])
    o = asoperator(np.matrix(p))
    r = BlockRowOperator([o, 2*o], axisin=0)
    assert_eq(r.todense(), np.hstack([p, 2*p]))
    assert_eq(r.T.todense(), r.todense().T)
    r = BlockRowOperator([o, 2*o], new_axisin=0)
    assert_eq(r.todense(), np.hstack([p, 2*p]))
    assert_eq(r.T.todense(), r.todense().T)
コード例 #28
0
 def func_rightward(a, key):
     b = a[key]
     if np.isscalar(b):
         assert b.dtype == np.float64
         return
     if key is Ellipsis:
         assert_eq(b.derived_units['r[rightward]'],
                   a.derived_units['r[rightward]'])
     if key in ((1, 2, 3), (1, 2, 3, 4), (1, 2, 3, _)):
         assert 'r' in b.derived_units
         assert b.derived_units['r'] == Quantity(23)
     else:
         assert 'r' not in b.derived_units
         if not isinstance(key, tuple):
             key = (key,)
         assert_eq(b.derived_units['r[rightward]'],
                   a.derived_units['r[rightward]'][key[:3]])
コード例 #29
0
 def func(n, s, m):
     if s is not Ellipsis:
         tmp = np.ones(n, bool)
         tmp[s] = False
         s = tmp
     layout = PackedTable(n, selection=s, val=np.arange(n)*2.)
     slices = layout.split(m)
     assert_eq(len(slices), m)
     o = np.zeros(layout.shape, int)
     v = np.full(layout.shape, np.nan)
     for s in slices:
         o[s._index] += 1
         v[s._index] = s.val
     o[o == 0] = -1
     assert_same(o, layout.unpack(1))
     assert_same(v, layout.all.val)
     assert_same(np.concatenate([_.val for _ in slices]), layout.val)
コード例 #30
0
 def func(c1, t1, c2, t2):
     op2 = ConstantOperator(c2, broadcast=t2)
     op = op1 + op2
     if set((op1.broadcast, op2.broadcast)) != \
        set(('rightward', 'leftward')):
         assert_is_instance(op, ConstantOperator)
     v = np.zeros((2, 3))
     op(np.nan, v)
     z = np.zeros((2, 3))
     if t1 == 'rightward':
         z.T[...] += c1.T
     else:
         z[...] += c1
     if t2 == 'rightward':
         z.T[...] += c2.T
     else:
         z[...] += c2
     assert_eq(v, z)
コード例 #31
0
ファイル: test_utils.py プロジェクト: pchanial/pyoperators
def test_settingerr():
    ref1 = np.seterr()
    ref2 = {"divide": "ignore", "invalid": "ignore", "over": "ignore", "under": "ignore"}
    ref3 = {"divide": "raise", "invalid": "ignore", "over": "warn", "under": "ignore"}

    with settingerr(all="ignore"):
        assert_eq(np.seterr(), ref2)
        with settingerr(divide="raise", over="warn"):
            assert_eq(np.seterr(), ref3)
        assert_eq(np.seterr(), ref2)
    assert_eq(np.seterr(), ref1)
コード例 #32
0
ファイル: test_utils.py プロジェクト: satorchi/pyoperators
def test_settingerr():
    ref1 = np.seterr()
    ref2 = {'divide': 'ignore', 'invalid': 'ignore', 'over': 'ignore',
            'under': 'ignore'}
    ref3 = {'divide': 'raise', 'invalid': 'ignore', 'over': 'warn',
            'under': 'ignore'}

    with settingerr(all='ignore'):
        assert_eq(np.seterr(), ref2)
        with settingerr(divide='raise', over='warn'):
            assert_eq(np.seterr(), ref3)
        assert_eq(np.seterr(), ref2)
    assert_eq(np.seterr(), ref1)
コード例 #33
0
 def func_leftward(a, key):
     b = a[key]
     if np.isscalar(b):
         assert b.dtype == np.float64
         return
     if key is Ellipsis:
         assert_eq(b.derived_units['r[leftward]'],
                   a.derived_units['r[leftward]'])
     if key in ((1, 2, 3, 4), (_, 1, 2, 3)):
         assert 'r' in b.derived_units
         if key == (1, 2, 3, 4):
             assert b.derived_units['r'] == Quantity(59)
         else:
             assert b.derived_units['r'] == Quantity(33)
     else:
         assert 'r' not in b.derived_units
         if not isinstance(key, tuple):
             key = (key,)
         key += (4-len(key)) * (slice(None),)
         assert_eq(b.derived_units['r[leftward]'],
                   a.derived_units['r[leftward]'][key[-3:]])
コード例 #34
0
 def func(s, v):
     layout = PackedTable((6, 6), key=v)
     assert 'key' in layout._special_attributes
     assert isscalarlike(layout.key)
     assert_eq(layout.key, v)
     assert_eq(layout.key.shape, ())
     assert_same(layout.all.key, v, broadcasting=True)
     assert_same(layout.all.key.shape, layout.shape)
     s(layout, 'key', v)
     assert isscalarlike(layout.key)
     assert_eq(layout.key, v)
     assert_eq(layout.key.shape, ())
     assert_same(layout.all.key, v, broadcasting=True)
     assert_same(layout.all.key.shape, layout.shape)
コード例 #35
0
def test1():
    q = Quantity(1, 'km')
    assert_eq(q.SI, Quantity(1000, 'm'))

    q = Quantity(1, 'm')
    assert_eq(q, q.tounit('m'))
    q2 = q.copy()
    q.inunit('m')
    assert_eq(q, q2)
コード例 #36
0
ファイル: test_identity.py プロジェクト: satorchi/pyoperators
 def func(op_, id_):
     op = op_(id_)
     assert_is_type(op, type(op_))
     attr = {}
     assert_is(op.classout, op_.classout)
     attr.update(id_.attrout)
     attr.update(op_.attrout)
     assert_eq(op.attrout, attr)
     assert_eq(op.flags.linear, op_.flags.linear)
     assert_eq(op.flags.contiguous_input, op_.flags.contiguous_input)
コード例 #37
0
ファイル: test_utils.py プロジェクト: satorchi/pyoperators
def test_izip_broadcast2():
    a = [1]
    b = (np.sin,)
    c = np.arange(3).reshape((1, 3))
    aa = []; bb = []; cc = []
    for a_, b_, c_ in izip_broadcast(a, b, c):
        aa.append(a_)
        bb.append(b_)
        cc.append(c_)
    assert_eq(aa, a)
    assert_eq(tuple(bb), b)
    assert_eq(cc, c)
コード例 #38
0
 def func(v):
     a = A()
     a.a, a.b, a.c = v
     if any(_ > 2 for _ in v):
         try:
             sc(a)
         except StopIteration as e:
             if a.a > 2:
                 assert_eq(str(e), str(sc1))
             elif a.b > 2:
                 assert_eq(str(e), str(sc2))
             else:
                 assert_eq(str(e), str(sc3))
コード例 #39
0
 def func(v):
     a = A()
     a.a, a.b, a.c = v
     if any(_ > 2 for _ in v):
         try:
             sc(a)
         except StopIteration as e:
             if a.a > 2:
                 assert_eq(str(e), str(sc1))
             elif a.b > 2:
                 assert_eq(str(e), str(sc2))
             else:
                 assert_eq(str(e), str(sc3))
コード例 #40
0
ファイル: test_utils.py プロジェクト: pchanial/pyoperators
def test_izip_broadcast2():
    a = [1]
    b = (np.sin,)
    c = np.arange(3).reshape((1, 3))
    aa = []
    bb = []
    cc = []
    for a_, b_, c_ in izip_broadcast(a, b, c):
        aa.append(a_)
        bb.append(b_)
        cc.append(c_)
    assert_eq(aa, a)
    assert_eq(tuple(bb), b)
    assert_eq(cc, c)
コード例 #41
0
def test_fibonacci():
    class Fibonacci(IterativeAlgorithm):
        def __init__(self, **keywords):
            IterativeAlgorithm.__init__(self, x_old=0, x=1, **keywords)

        def iteration(self):
            np.add(self.x_old, self.x, self.x_new)

        def finalize(self):
            return int(self.x)

    fib = Fibonacci(normal_stop_condition=MaxIterationStopCondition(10))
    assert_eq(fib.run(), 55)
    fib.initialize()
    assert_eq(list(fib), [1, 2, 3, 5, 8, 13, 21, 34, 55])
    assert_eq(fib.restart(), 55)
コード例 #42
0
 def func(n):
     assert_eq(d.todense(shapein=n), d.todense(shapein=n, inplace=True))
     assert_eq(d.T.todense(shapein=n), d.T.todense(shapein=n, inplace=True))
コード例 #43
0
ファイル: test_utils.py プロジェクト: satorchi/pyoperators
 def func(dtype, expected):
     if expected is None:
         assert_raises(TypeError, float_dtype, dtype)
     else:
         actual = float_dtype(dtype)
         assert_eq(actual, expected)
コード例 #44
0
 def func(shape, dtype):
     x_global = np.ones(shape, dtype)
     d = MPIDistributionIdentityOperator()
     assert_eq(d(x_global), x_global)
     x_local = x_global * (rank + 1)
     assert_eq(d.T(x_local), np.ones(shape) * size * (size + 1) // 2)
コード例 #45
0
def test_multiple_pointings():
    ra = (23, 24)
    dec = (50, 51)
    instrument_angle=(10, 11)
    scan_angle = (0, -90)
    scan_length = (10, 20)
    scan_nlegs = (2, 3)
    scan_step = (147, 149)
    scan_speed = (20, 60)
    compression_factor = (4, 4)
    acc = PacsSimulation.ACCELERATION

    pointings = [PacsObservation.create_scan((r,d),sl,sst,None,ssp,acc,sn,sa,ia,
                 cf,False) for r,d,ia,sa,sl,sn,sst,ssp,cf in zip(ra,dec,
                 instrument_angle,scan_angle,scan_length,scan_nlegs,scan_step,
                 scan_speed,compression_factor)]
    simul = PacsSimulation(pointings, 'blue')
    s = simul.slice
    assert len(s) == 2
    assert_eq(s.ra, ra)
    assert_eq(s.dec, dec)
    assert_eq(s.instrument_angle, instrument_angle)
    assert_eq(s.scan_angle, scan_angle)
    assert_eq(s.scan_length, scan_length)
    assert_eq(s.scan_nlegs, scan_nlegs)
    assert_eq(s.scan_step, scan_step)
    assert_eq(s.scan_speed, scan_speed)
    assert_eq(s.compression_factor, compression_factor)
コード例 #46
0
 def func(o, e):
     layout = PackedTable((2, 3), ordering=o)
     assert_eq(layout._index, e)
コード例 #47
0
ファイル: test_utils.py プロジェクト: satorchi/pyoperators
def test_strenum():
    assert_eq(strenum(['blue', 'red', 'yellow'], 'or'),
              "'blue', 'red' or 'yellow'")
コード例 #48
0
def test_mask_policy1():
    good_policy = ['kEep', 'removE', 'MASK']
    mask_policy = MaskPolicy(flags, good_policy)
    assert_eq(np.array(mask_policy), (0, 2, 1))
    assert mask_policy.bad == 'keep' and mask_policy.u1 == 'remove' and \
        mask_policy.u2 == 'mask'
コード例 #49
0
ファイル: test_utils.py プロジェクト: satorchi/pyoperators
 def func(n, nonumber, s, expected):
     assert_eq(strplural(n, 'cat', nonumber=nonumber, s=s), expected)