Skip to content

Commit

Permalink
Doc updates for 10.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bbayles committed Aug 2, 2023
1 parent cc8a8ab commit e470f77
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Python iterables.
| | `random_combination_with_replacement <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.random_combination_with_replacement>`_, |
| | `nth_product <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.nth_product>`_, |
| | `nth_permutation <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.nth_permutation>`_, |
| | `nth_combination <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.nth_combination>`_ |
| | `nth_combination <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.nth_combination>`_, |
| | `nth_combination_with_replacement <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.nth_combination_with_replacement>`_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Wrapping | `always_iterable <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.always_iterable>`_, |
Expand Down Expand Up @@ -158,7 +158,7 @@ Python iterables.
| | `polynomial_derivative <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.polynomial_derivative>`_, |
| | `sieve <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.sieve>`_, |
| | `factor <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.factor>`_, |
| | `matmul <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.matmul>`_ |
| | `matmul <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.matmul>`_, |
| | `sum_of_squares <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.sum_of_squares>`_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Expand Down
2 changes: 2 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ These tools yield certain items from an iterable.
.. autofunction:: duplicates_everseen
.. autofunction:: duplicates_justseen
.. autofunction:: longest_common_prefix
.. autofunction:: takewhile_inclusive

----

Expand Down Expand Up @@ -229,6 +230,7 @@ These tools yield combinatorial arrangements of items from iterables.
.. autofunction:: permutation_index
.. autofunction:: combination_with_replacement_index
.. autofunction:: gray_product
.. autofunction:: outer_product

----

Expand Down
14 changes: 14 additions & 0 deletions docs/versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ Version History
.. automodule:: more_itertools
:noindex:

10.1.0
------

* New functions
* :func:`takewhile_inclusive` (thanks to OlegAlexander)
* :func:`outer_product` (thanks to OlegAlexander)

* Changes to existing functions
* :func:`zip_broadcast` was improved (thanks to kalekundert and pochmann)
* :func:`consume` had its type annotation fixed (thanks to obaltian)

* Other changes
* Some documentation and testing issues were fixed (thanks to OlegAlexander)

10.0.0
------

Expand Down
10 changes: 7 additions & 3 deletions more_itertools/more.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
'numeric_range',
'one',
'only',
'outer_product',
'padded',
'partial_product',
'partitions',
Expand Down Expand Up @@ -130,6 +131,7 @@
'strictly_n',
'substrings',
'substrings_indexes',
'takewhile_inclusive',
'time_limited',
'unique_in_window',
'unique_to_each',
Expand All @@ -141,8 +143,6 @@
'zip_broadcast',
'zip_equal',
'zip_offset',
'takewhile_inclusive',
'outer_product',
]


Expand Down Expand Up @@ -4538,14 +4538,17 @@ def takewhile_inclusive(predicate, iterable):

def outer_product(func, xs, ys, *args, **kwargs):
"""A generalized outer product that applies a binary function to all
pairs of items. Returns a 2D matrix with len(xs) rows and len(ys) columns.
pairs of items. Returns a 2D matrix with ``len(xs)`` rows and ``len(ys)``
columns.
Also accepts ``*args`` and ``**kwargs`` that are passed to ``func``.
Multiplication table:
>>> list(outer_product(mul, range(1, 4), range(1, 6)))
[(1, 2, 3, 4, 5), (2, 4, 6, 8, 10), (3, 6, 9, 12, 15)]
Cross tabulation:
>>> xs = ['A', 'B', 'A', 'A', 'B', 'B', 'A', 'A', 'B', 'B']
>>> ys = ['X', 'X', 'X', 'Y', 'Z', 'Z', 'Y', 'Y', 'Z', 'Z']
>>> rows = list(zip(xs, ys))
Expand All @@ -4554,6 +4557,7 @@ def outer_product(func, xs, ys, *args, **kwargs):
[(2, 3, 0), (1, 0, 4)]
Usage with ``*args`` and ``**kwargs``:
>>> animals = ['cat', 'wolf', 'mouse']
>>> list(outer_product(min, animals, animals, key=len))
[('cat', 'cat', 'cat'), ('cat', 'wolf', 'wolf'), ('cat', 'wolf', 'mouse')]
Expand Down

0 comments on commit e470f77

Please sign in to comment.