Beispiel #1
0
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()
Beispiel #2
0
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()
Beispiel #3
0
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()
Beispiel #4
0
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()
Beispiel #5
0
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()
Beispiel #6
0
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()
Beispiel #7
0
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()
Beispiel #8
0
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()