Exemplo n.º 1
0
 def func(d1, d2):
     a1 = None if d1 is None else np.array(1, dtype=d1)
     a2 = None if d2 is None else np.array(1, dtype=d2)
     if d1 is None and d2 is None:
         assert_raises(ValueError, cast, [a1, a2])
         return
     expected = d1 if d2 is None else d2 if d1 is None else np.promote_types(d1, d2)
     a1_, a2_ = cast([a1, a2])
     assert_dtype(a1_, expected)
     assert_dtype(a2_, expected)
Exemplo n.º 2
0
 def func(d1, d2):
     a1 = None if d1 is None else np.array(1, dtype=d1)
     a2 = None if d2 is None else np.array(1, dtype=d2)
     if d1 is None and d2 is None:
         assert_raises(ValueError, cast, [a1, a2])
         return
     expected = d1 if d2 is None else d2 if d1 is None else \
         np.promote_types(d1, d2)
     a1_, a2_ = cast([a1, a2])
     assert_dtype(a1_, expected)
     assert_dtype(a2_, expected)
Exemplo n.º 3
0
 def func(algo, reuse_initial_state):
     g = algo(reuse_initial_state=reuse_initial_state)
     pi = g.run()
     assert g.niterations == 10
     assert_same(pi, np.pi)
     if g.reuse_initial_state:
         assert_raises(RuntimeError, g.restart)
         return
     g.restart()
     assert g.niterations == 10
     assert_same(pi, np.pi)
Exemplo n.º 4
0
def test_healpix_spherical_error():
    assert_raises(ValueError, Healpix2SphericalOperator, NSIDE, 'bla')
    op = Healpix2SphericalOperator(NSIDE, 'zenith,azimuth')

    def func(i, o):
        if i.shape == () and o.shape == (2,):
            op(i, o)
            return
        assert_raises(ValueError, op.__call__, i, o)
    for i, o in itertools.product((np.array(1.), np.zeros(2), np.zeros(3)),
                                  (np.array(1.), np.zeros(2), np.zeros(3))):
        yield func, i, o
Exemplo n.º 5
0
def test_healpix_spherical_error():
    assert_raises(ValueError, Healpix2SphericalOperator, NSIDE, 'bla')
    op = Healpix2SphericalOperator(NSIDE, 'zenith,azimuth')

    def func(i, o):
        if i.shape == () and o.shape == (2, ):
            op(i, o)
            return
        assert_raises(ValueError, op.__call__, i, o)

    for i, o in itertools.product((np.array(1.), np.zeros(2), np.zeros(3)),
                                  (np.array(1.), np.zeros(2), np.zeros(3))):
        yield func, i, o
Exemplo n.º 6
0
def test_healpix_convolution_errors():
    assert_raises(ValueError, HealpixConvolutionGaussianOperator, iter=2)
    assert_raises(ValueError, HealpixConvolutionGaussianOperator, fwhm=-1)
    assert_raises(ValueError, HealpixConvolutionGaussianOperator, sigma=-1)
    assert_raises(ValueError,
                  HealpixConvolutionGaussianOperator,
                  fwhm=1,
                  sigma=1)
Exemplo n.º 7
0
def test_ifirst_is_not():
    assert ifirst_is_not([1, 2, 2], 2) == 0
    assert ifirst_is_not([2, 1, 1], 2) == 1
    assert ifirst_is_not([{}, None, None], None) == 0
    assert_raises(ValueError, ifirst_is_not, [], None)
    assert_raises(ValueError, ifirst_is_not, [None, None], None,)

    assert ilast_is_not([1, 2, 2], 2) == 0
    assert ilast_is_not([2, 1, 1], 2) == 2
    assert ilast_is_not([{}, None, None], None) == 0
    assert_raises(ValueError, ilast_is_not, [], None)
    assert_raises(ValueError, ilast_is_not, [None, None], None,)
Exemplo n.º 8
0
def test_ifirst_is_not():
    assert ifirst_is_not([1, 2, 2], 2) == 0
    assert ifirst_is_not([2, 1, 1], 2) == 1
    assert ifirst_is_not([{}, None, None], None) == 0
    assert_raises(ValueError, ifirst_is_not, [], None)
    assert_raises(ValueError, ifirst_is_not, [None, None], None)

    assert ilast_is_not([1, 2, 2], 2) == 0
    assert ilast_is_not([2, 1, 1], 2) == 2
    assert ilast_is_not([{}, None, None], None) == 0
    assert_raises(ValueError, ilast_is_not, [], None)
    assert_raises(ValueError, ilast_is_not, [None, None], None)
Exemplo n.º 9
0
def test_error():
    assert_raises(ValueError, Imager, "instrument", (3, 2))
Exemplo n.º 10
0
def test_block_row1():
    I2 = IdentityOperator(2)
    I3 = IdentityOperator(3)
    assert_raises(ValueError, BlockRowOperator, [I2, 2*I3], axisin=0)
    assert_raises(ValueError, BlockRowOperator, [I2, 2*I3], new_axisin=0)
Exemplo n.º 11
0
def test_block_column1():
    I2 = IdentityOperator(2)
    I3 = IdentityOperator(3)
    assert_raises(ValueError, BlockColumnOperator, [I2, 2*I3], axisout=0)
    assert_raises(ValueError, BlockColumnOperator, [I2, 2*I3], new_axisout=0)
Exemplo n.º 12
0
 def func(dtype, expected):
     if expected is None:
         assert_raises(TypeError, float_dtype, dtype)
     else:
         actual = float_dtype(dtype)
         assert_eq(actual, expected)
Exemplo n.º 13
0
def test_block_row1():
    I2 = IdentityOperator(2)
    I3 = IdentityOperator(3)
    assert_raises(ValueError, BlockRowOperator, [I2, 2 * I3], axisin=0)
    assert_raises(ValueError, BlockRowOperator, [I2, 2 * I3], new_axisin=0)
Exemplo n.º 14
0
 def func(x):
     assert_raises(TypeError, strshape, x)
Exemplo n.º 15
0
def test_block_column1():
    I2 = IdentityOperator(2)
    I3 = IdentityOperator(3)
    assert_raises(ValueError, BlockColumnOperator, [I2, 2 * I3], axisout=0)
    assert_raises(ValueError, BlockColumnOperator, [I2, 2 * I3], new_axisout=0)
Exemplo n.º 16
0
 def func(v):
     a = A()
     a.a = v
     if v > 2:
         assert_raises(StopIteration, sc1, a)
Exemplo n.º 17
0
def test_ifirst2():
    assert_raises(ValueError, ifirst, [1, 2, 3], lambda x: x > 3)
    assert_raises(ValueError, ilast, [1, 2, 3], lambda x: x > 3)
Exemplo n.º 18
0
def test_error():
    assert_raises(ValueError, Imager, 'instrument', (3, 2))
Exemplo n.º 19
0
def test_mask_policy2():
    bad_policy = ['remove', 'KKeep']
    assert_raises(ValueError, MaskPolicy, flags, bad_policy)
    assert_raises(KeyError, MaskPolicy, flags[0:2], bad_policy)
Exemplo n.º 20
0
def test_healpix_convolution_errors():
    assert_raises(ValueError, HealpixConvolutionGaussianOperator, iter=2)
    assert_raises(ValueError, HealpixConvolutionGaussianOperator, fwhm=-1)
    assert_raises(ValueError, HealpixConvolutionGaussianOperator, sigma=-1)
    assert_raises(ValueError, HealpixConvolutionGaussianOperator, fwhm=1,
                  sigma=1)
Exemplo n.º 21
0
 def func(i, o):
     if i.shape == () and o.shape == (3,):
         op(i, o)
         return
     assert_raises(ValueError, op.__call__, i, o)
Exemplo n.º 22
0
 def func(dtype, expected):
     if expected is None:
         assert_raises(TypeError, float_dtype, dtype)
     else:
         actual = float_dtype(dtype)
         assert_eq(actual, expected)
Exemplo n.º 23
0
 def func(i, o):
     if i.shape == () and o.shape == (3, ):
         op(i, o)
         return
     assert_raises(ValueError, op.__call__, i, o)
Exemplo n.º 24
0
def test_ifirst4():
    assert_raises(ValueError, ifirst, [1, 2, 3], 4)
    assert_raises(ValueError, ilast, [1, 2, 3], 4)
Exemplo n.º 25
0
def test_ifirst2():
    assert_raises(ValueError, ifirst, [1, 2, 3], lambda x: x > 3)
    assert_raises(ValueError, ilast, [1, 2, 3], lambda x: x > 3)
Exemplo n.º 26
0
 def func(x):
     assert_raises(TypeError, strshape, x)
Exemplo n.º 27
0
def test_ifirst4():
    assert_raises(ValueError, ifirst, [1, 2, 3], 4)
    assert_raises(ValueError, ilast, [1, 2, 3], 4)
Exemplo n.º 28
0
def test_mask_policy2():
    bad_policy = ['remove', 'KKeep']
    assert_raises(ValueError, MaskPolicy, flags, bad_policy)
    assert_raises(KeyError, MaskPolicy, flags[0:2], bad_policy)
Exemplo n.º 29
0
 def func(v):
     a = A()
     a.a = v
     if v > 2:
         assert_raises(StopIteration, sc1, a)