Skip to content

Commit

Permalink
update 5 files update README.md and test_arr.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBernstorff committed Feb 7, 2025
1 parent 13638d8 commit d2f594d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions iterpy/arr.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def clone(self) -> Arr[T]:
def zip(self, other: Arr[S]) -> Arr[tuple[T, S]]:
return Arr(zip(self, other))

def chain(self, other: Arr[T]) -> Arr[T]:
return self.lazy().chain(other).collect()

############################################################
# Auto-generated overloads for flatten #
# Code for generating the following is in _generate_pyi.py #
Expand Down
3 changes: 3 additions & 0 deletions iterpy/iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def clone(self) -> Iter[T]:
def zip(self, other: Iter[S]) -> Iter[tuple[T, S]]:
return Iter(zip(self, other))

def chain(self, other: Iter[T]) -> Iter[T]:
return Iter((*self, *other))

############################################################
# Auto-generated overloads for flatten #
# Code for generating the following is in _generate_pyi.py #
Expand Down
6 changes: 6 additions & 0 deletions iterpy/test_arr.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def test_looping():
for i in test_iterator:
assert i in [1, 2, 3]

def test_chain():
iterator = Arr([1, 2])
iterator2 = Arr([3, 4])
result: list[int] = iterator.chain(iterator2).to_list()
assert result == [1, 2, 3, 4]


@pytest.mark.benchmark()
def test_benchmark_large_flattening():
Expand Down
6 changes: 6 additions & 0 deletions iterpy/test_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def test_looping():
for i in test_iterator:
assert i in [1, 2, 3]

def test_chain():
iterator = Iter([1, 2])
iterator2 = Iter([3, 4])
result: list[int] = iterator.chain(iterator2).to_list()
assert result == [1, 2, 3, 4]


@pytest.mark.benchmark()
def test_benchmark_large_flattening():
Expand Down

0 comments on commit d2f594d

Please # to comment.