def test_vec_slice_contig_inplace(): a_orig = numpy.ones((10, ), dtype=float) a = a_orig[4:7] te.dbl_numpy_vec_inplace(a) assert (a_orig[4:7] == 2).all() assert (a_orig[0:4] == 1).all() assert (a_orig[7:10] == 1).all()
def test_vec_slice_contig_inplace(): a_orig = numpy.ones((10,), dtype=float) a = a_orig[4:7] te.dbl_numpy_vec_inplace(a) assert (a_orig[4:7] == 2).all() assert (a_orig[0:4] == 1).all() assert (a_orig[7:10] == 1).all()
def test_2d(): a = numpy.ones((10, 10), dtype=float) te.dbl_numpy_vec_inplace(a) assert (a == 2).all() a_orig = numpy.ones((10, 10), dtype=float) a = a_orig[::-1, ::-1] te.dbl_numpy_vec_inplace(a) assert (a_orig == 2).all()
def test_vec_slice_noncontig_inplace(): a_orig = numpy.ones((10, ), dtype=float) a = a_orig[::2] te.dbl_numpy_vec_inplace(a) assert (a_orig == 2).all() a_orig = numpy.ones((10, ), dtype=float) a = a_orig[::2] te.dbl_numpy_strided_vec_inplace(a) assert (a_orig[::2] == 2).all() assert (a_orig[1::2] == 1).all()
def test_vec_slice_noncontig_inplace(): a_orig = numpy.ones((10,), dtype=float) a = a_orig[::2] te.dbl_numpy_vec_inplace(a) assert (a_orig == 2).all() a_orig = numpy.ones((10,), dtype=float) a = a_orig[::2] te.dbl_numpy_strided_vec_inplace(a) assert (a_orig[::2] == 2).all() assert (a_orig[1::2] == 1).all()
def test_negative_stride(): a_orig = numpy.ones((10, ), dtype=float) a = a_orig[::-2] te.dbl_numpy_vec_inplace(a) assert (a_orig[1:] == 2).all() assert (a_orig[0] == 1).all() a_orig = numpy.ones((10, ), dtype=float) a = a_orig[::-2] te.dbl_numpy_strided_vec_inplace(a) assert (a_orig[::-2] == 2).all() assert (a_orig[-2::-2] == 1).all()
def test_negative_stride(): a_orig = numpy.ones((10,), dtype=float) a = a_orig[::-2] te.dbl_numpy_vec_inplace(a) assert (a_orig[1:] == 2).all() assert (a_orig[0] == 1).all() a_orig = numpy.ones((10,), dtype=float) a = a_orig[::-2] te.dbl_numpy_strided_vec_inplace(a) assert (a_orig[::-2] == 2).all() assert (a_orig[-2::-2] == 1).all()