From e385603b230b7c9502c11ebd33fc433ec2fa7c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Thu, 17 Oct 2024 10:37:46 +0200 Subject: [PATCH] docs fixes --- CHANGELOG.md | 1 + docs/coding/sequences.rst | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aea11df9..b8e0518e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # v2.25.8 * fixed the modules page in documentation +* added choose_with_index # v2.25.7 diff --git a/docs/coding/sequences.rst b/docs/coding/sequences.rst index 777cd9ad..d0e9f8be 100644 --- a/docs/coding/sequences.rst +++ b/docs/coding/sequences.rst @@ -1,6 +1,5 @@ -======================= Sequences and iterators -======================= +####################### Rolling averages ================ @@ -42,22 +41,21 @@ iterate_callable .. autofunction:: satella.coding.sequences.iterate_callable -choose ------- +Choosing stuff +-------------- To return the first single element that returns true on given callable, use the following function: .. autofunction:: satella.coding.sequences.choose -choose_one ----------- - -Does the same thing as choose, but exhausts the generator and checks if there are no multiple -elements matching the callable. If there are, raises ValueError. +If you need to exhaust the generator, use the following: .. autofunction:: satella.coding.sequences.choose_one +If you needn an index of the element found, use: + +.. autofunction:: satella.coding.sequences.choose_with_index AlreadySeen ----------- @@ -115,7 +113,7 @@ take_n For the rare moments, when you wish you could just do: -:: +.. code-block:: python iterator: tp.Iterator[T] = iterator n_elements: tp.List[T] = iterator[:n] @@ -125,7 +123,6 @@ However, this function comes to the rescue: .. autofunction:: satella.coding.sequences.take_n - infinite_iterator ----------------- @@ -139,7 +136,7 @@ A factory for filter functions that check if given object is an instance of something (or multiple classes, if passed a tuple of classes). Use like that -:: +.. code-block:: python orders: tp.List[BaseOrder] = ... read_orders = filter(is_instance(ReadOrder), orders) @@ -206,7 +203,7 @@ zip_shifted .. autofunction:: satella.coding.sequences.zip_shifted -This is deprecated. Use ``zip(shift(...))`` instead. +This is deprecated. Use :code:`zip(shift(...))`` instead. stop_after -- GitLab