Skip to content

Commit

Permalink
new test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Bchass committed Jul 2, 2024
1 parent 7991bf2 commit 900fb88
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tinynumpy/tests/test_tinynumpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,33 @@ def test_getitem():
a = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
b = tnp.array([[1, 2, 3, 4], [5, 6, 7, 8]])


def test_get_step():
# Test for C-contiguous arrays
c_array = np.array([[1, 2, 3], [4, 5, 6]], order='C')
tnp_c_array = tnp.array([[1, 2, 3], [4, 5, 6]], order='C')
assert tnp._get_step(c_array) == 1
assert tnp._get_step(tnp_c_array) == 1

# Test for F-contiguous arrays
f_array = np.array([[1, 2, 3], [4, 5, 6]], order='F')
tnp_f_array = tnp.array([[1, 2, 3], [4, 5, 6]], order='F')
assert tnp._get_step(f_array) == 0
assert tnp._get_step(tnp_f_array) == 0

# Test for non-contiguous arrays
nc_array = c_array[:, ::2]
tnp_nc_array = tnp_c_array[:, ::2]
assert tnp._get_step(nc_array) == 0
assert tnp._get_step(tnp_nc_array) == 0

# Test for non-contiguous arrays with Fortran order
f_nc_array = f_array[::2, :]
tnp_f_nc_array = tnp_f_array[::2, :]
assert tnp._get_step(f_nc_array) == 0
assert tnp._get_step(tnp_f_nc_array) == 0


def test_setitem_writeable():

a = tnp.array([1, 2, 3])
Expand Down

0 comments on commit 900fb88

Please sign in to comment.