Skip to content

Commit

Permalink
test slicing
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Jun 18, 2024
1 parent a1c75ec commit 350b3b5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dynamicsizerecarray/tests/test_slicing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import dynamicsizerecarray
import pytest


def test_slice():
dra = dynamicsizerecarray.DynamicSizeRecarray(
dtype=[("a", "i8"), ("b", "u2")]
)

for i in range(100):
dra.append_record({"a": 2 * i, "b": i})

with pytest.raises(IndexError):
_ = dra[200]

s = dra[10:20]
for idx, val in enumerate(range(10, 20)):
assert s["b"][idx] == val

s = dra[10:2:20]
for idx, val in enumerate(range(10, 2, 20)):
assert s["b"][idx] == val

0 comments on commit 350b3b5

Please sign in to comment.