Skip to content

Commit

Permalink
fix typo 'even'
Browse files Browse the repository at this point in the history
  • Loading branch information
ebonnal committed Dec 22, 2024
1 parent c8dca54 commit a2365b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ assert state == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> Keeps only the elements that satisfy a condition:
```python
pair_integers: Stream[int] = integers.filter(lambda n: n % 2 == 0)
even_integers: Stream[int] = integers.filter(lambda n: n % 2 == 0)

assert list(pair_integers) == [0, 2, 4, 6, 8]
assert list(even_integers) == [0, 2, 4, 6, 8]
```

# `.throttle`
Expand Down Expand Up @@ -285,10 +285,10 @@ assert list(integers_by_parity_by_2) == [[0, 2], [1, 3], [4, 6], [5, 7], [8], [9
```python
integers_by_parity: Stream[Tuple[str, List[int]]] = (
integers
.groupby(lambda n: "odd" if n % 2 else "pair")
.groupby(lambda n: "odd" if n % 2 else "even")
)

assert list(integers_by_parity) == [("pair", [0, 2, 4, 6, 8]), ("odd", [1, 3, 5, 7, 9])]
assert list(integers_by_parity) == [("even", [0, 2, 4, 6, 8]), ("odd", [1, 3, 5, 7, 9])]
```

> [!TIP]
Expand All @@ -302,17 +302,17 @@ counts_by_parity: Stream[Tuple[str, int]] = (
.map(star(lambda parity, ints: (parity, len(ints))))
)

assert list(counts_by_parity) == [("pair", 5), ("odd", 5)]
assert list(counts_by_parity) == [("even", 5), ("odd", 5)]
```

# `.flatten`

> Ungroups elements assuming that they are `Iterable`s:
```python
pair_then_odd_integers: Stream[int] = integers_by_parity.flatten()
even_then_odd_integers: Stream[int] = integers_by_parity.flatten()

assert list(pair_then_odd_integers) == [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
assert list(even_then_odd_integers) == [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
```

### thread-based concurrency
Expand Down
14 changes: 7 additions & 7 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def test_foreach_example(self) -> None:
assert state == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

def test_filter_example(self) -> None:
pair_integers: Stream[int] = integers.filter(lambda n: n % 2 == 0)
even_integers: Stream[int] = integers.filter(lambda n: n % 2 == 0)

assert list(pair_integers) == [0, 2, 4, 6, 8]
assert list(even_integers) == [0, 2, 4, 6, 8]

def test_throttle_example(self) -> None:

Expand Down Expand Up @@ -152,10 +152,10 @@ def test_group_example(self) -> None:
def test_groupby_example(self) -> None:
integers_by_parity: Stream[Tuple[str, List[int]]] = (
integers
.groupby(lambda n: "odd" if n % 2 else "pair")
.groupby(lambda n: "odd" if n % 2 else "even")
)

assert list(integers_by_parity) == [("pair", [0, 2, 4, 6, 8]), ("odd", [1, 3, 5, 7, 9])]
assert list(integers_by_parity) == [("even", [0, 2, 4, 6, 8]), ("odd", [1, 3, 5, 7, 9])]

from streamable import star

Expand All @@ -164,13 +164,13 @@ def test_groupby_example(self) -> None:
.map(star(lambda parity, ints: (parity, len(ints))))
)

assert list(counts_by_parity) == [("pair", 5), ("odd", 5)]
assert list(counts_by_parity) == [("even", 5), ("odd", 5)]

def test_flatten_example(self) -> None:
global integers_by_parity
pair_then_odd_integers: Stream[int] = integers_by_parity.flatten()
even_then_odd_integers: Stream[int] = integers_by_parity.flatten()

assert list(pair_then_odd_integers) == [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
assert list(even_then_odd_integers) == [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]

mixed_ones_and_zeros: Stream[int] = (
Stream([[0] * 4, [1] * 4])
Expand Down
6 changes: 3 additions & 3 deletions tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class TestError(Exception):

src = range(N)

pair_src = range(0, N, 2)
even_src = range(0, N, 2)


def randomly_slowed(
Expand Down Expand Up @@ -570,7 +570,7 @@ def test_map_or_foreach_with_exception(
list(
method(Stream(src), throw_for_odd_func(raised_exc), concurrency).catch(catched_exc) # type: ignore
),
list(pair_src),
list(even_src),
msg="At any concurrency, `map` and `foreach` and `amap` must not stop after one exception occured.",
)

Expand Down Expand Up @@ -1010,7 +1010,7 @@ def f(i):
),
)
),
list(map(lambda e: [e, e + 1], pair_src)),
list(map(lambda e: [e, e + 1], even_src)),
msg="`group` should yield upstream elements in a two-element group if `interval` inferior to twice the upstream yield period",
)

Expand Down

0 comments on commit a2365b9

Please sign in to comment.