diff --git a/README.md b/README.md index c164823..c9298b2 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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] @@ -302,7 +302,7 @@ 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` @@ -310,9 +310,9 @@ assert list(counts_by_parity) == [("pair", 5), ("odd", 5)] > 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 diff --git a/tests/test_readme.py b/tests/test_readme.py index 9c7736c..aa69fe8 100644 --- a/tests/test_readme.py +++ b/tests/test_readme.py @@ -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: @@ -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 @@ -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]) diff --git a/tests/test_stream.py b/tests/test_stream.py index 2716681..8771308 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -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( @@ -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.", ) @@ -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", )