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)
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)
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)
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
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
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)
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,)
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)
def test_error(): assert_raises(ValueError, Imager, "instrument", (3, 2))
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)
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)
def func(dtype, expected): if expected is None: assert_raises(TypeError, float_dtype, dtype) else: actual = float_dtype(dtype) assert_eq(actual, expected)
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)
def func(x): assert_raises(TypeError, strshape, x)
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)
def func(v): a = A() a.a = v if v > 2: assert_raises(StopIteration, sc1, a)
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)
def test_error(): assert_raises(ValueError, Imager, 'instrument', (3, 2))
def test_mask_policy2(): bad_policy = ['remove', 'KKeep'] assert_raises(ValueError, MaskPolicy, flags, bad_policy) assert_raises(KeyError, MaskPolicy, flags[0:2], bad_policy)
def func(i, o): if i.shape == () and o.shape == (3,): op(i, o) return assert_raises(ValueError, op.__call__, i, o)
def func(i, o): if i.shape == () and o.shape == (3, ): op(i, o) return assert_raises(ValueError, op.__call__, i, o)
def test_ifirst4(): assert_raises(ValueError, ifirst, [1, 2, 3], 4) assert_raises(ValueError, ilast, [1, 2, 3], 4)