Example #1
0
    def test_no_2d_strided_vector(self):
        a_orig = numpy.ones((10,10), dtype=float)
        a = a_orig[:3, :3]

        try:
            te.dbl_numpy_strided_vec_inplace(a)
            assert False
        except ValueError:
            pass
Example #2
0
    def test_vec_slice_noncontig_inplace(self):
        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()
Example #3
0
    def test_negative_stride(self):
        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()