Skip to content

Commit

Permalink
chore(docs): small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jeertmans committed Oct 3, 2024
1 parent 5249d38 commit 16540e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions differt/src/differt/rt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# ruff: noqa: ERA001

import sys
from collections.abc import Callable, Iterator
from collections.abc import Callable, Iterator, Sized
from typing import Any, Generic, TypeVar

import equinox as eqx
Expand All @@ -48,9 +48,13 @@
T = TypeVar("T")

@typechecker
class SizedIterator(Iterator, Generic[T]):
class SizedIterator(Iterator, Sized, Generic[T]):
"""A custom generatic class that is both :class:`Iterator<collections.abc.Iterator>` and :class:`Sized<collections.abc.Sized>`.
The main purpose of this class is to be able to use
`tqdm <https://github.com/tqdm/tqdm>`_ utilities
on iterators and have some meaningful information about how iterations are left.
Args:
iter_: The iterator.
size: The size, i.e., length, of the iterator, or a callable that returns its current length.
Expand Down
3 changes: 2 additions & 1 deletion docs/source/notebooks/type_checking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@
"The error message is a bit verbose,\n",
"but we can see at the end that we expected `Shaped[Array, 'm n']`\n",
"and we received `i32[2,10,4]` (i.e., `Int32[Array, \"2 10 4\"]`).\n",
"`Int32` is a subclass of `Shaped`, but `m n` cannot be matched to `2 10 4`, as there is\n",
"{class}`Int32<jaxtyping.Int32>` is a subclass of {class}`Shaped<jaxtyping.Shaped>`, \n",
"but `m n` cannot be matched to `2 10 4`, as there is\n",
"one extra dimension. Thus, an error was raised for that reason."
]
},
Expand Down

0 comments on commit 16540e0

Please sign in to comment.