Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@ jobs:
python-version: ["3.12", "3.13", "3.14"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: "Setup uv ${{ matrix.python-version }} / ${{ matrix.os }}"
uses: astral-sh/setup-uv@v5
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
with:
python-version: ${{ matrix.python-version }}
- name: Build
run: uv sync --dev
- name: Lint
run: |
uv run ruff check
uv run mypy .
uv run ty check src
- name: Test
run: |
uv run pytest
- name: Upload coverage report
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
if: ${{ (runner.os == 'Linux') && (matrix.python-version == '3.13') }}
with:
name: coverage-html-${{ matrix.os }}-${{ matrix.python-version }}
path: htmlcov/
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
contents: read # Required to checkout the repository code

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Install prerequisites
uses: astral-sh/setup-uv@v5
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
- name: Install project
run: uv sync --all-groups
- name: Build wheel
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ __pycache__/
coverage.info

.env
uv.lock
.python-version

.coverage
Expand Down
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
repos:
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.11.5
hooks:
- id: uv-lock
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.9
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format
# doesn't exist (yet)
# - repo: https://github.com/astral-sh/ty-pre-commit

2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT Licence

Copyright © 2025 Andrew Smith
Copyright © 2025-2026 Andrew Smith

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ For a complete list of `Itr` methods and their detailed descriptions, please ref

## Examples

Some worked examples can be found [in this notebook](./doc/examples.ipynb).
Some worked examples can be found [in this notebook](./doc/examples.ipynb). Use e.g. `pip install itrx[examples]` to resolve the extra dependencies.
34 changes: 16 additions & 18 deletions doc/apidoc.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `Itr` v0.2.0 class documentation
# `Itr` v0.2.2 class documentation
A generic iterator adaptor class inspired by Rust's Iterator trait, providing a composable API for
functional-style iteration and transformation over Python iterables.
## Public methods
Expand Down Expand Up @@ -457,7 +457,13 @@ Raises:
### `product`


Creates a new iterator over tuples of the combinations of self and the other iterator
Creates a new iterator over the cartesian product of self and the other iterator

Args:
other (Iterable[U]): Another iterable.

Returns:
Itr[tuple[T, U]]: Iterator of 2-tuples with elements from each input iterator.


### `reduce`
Expand Down Expand Up @@ -591,23 +597,16 @@ This method calls itertools.tee on the wrapped iterator and returns a tuple of I
objects, each wrapping one of the tee'd iterators. Each returned Itr yields the same
sequence of items and can be consumed independently of the others.

Parameters
----------
n : int, optional
Number of independent iterators to create (default: 2). Must be >= 1.
Args:
n (int, optional): Number of independent iterators to create (default: 2). Must be >= 1.

Returns
-------
tuple[Itr[T], ...]
Tuple of length `n` containing the newly created Itr objects.
Returns:
tuple[Itr[T], ...]: Tuple of length `n` containing the newly created Itr objects.

Raises
------
ValueError
If `n` is less than 1.
Raises:
ValueError: If `n` is less than 1.

Notes
-----
Notes:
- The implementation uses itertools.tee; the tee'd iterators share internal buffers
that store items produced by the original iterator until all tees have consumed them.
If one or more returned iterators lag behind the others, buffered items will be
Expand All @@ -618,8 +617,7 @@ Notes
- Creating the tees is inexpensive, but the memory characteristics depend on how the
resulting iterators are consumed relative to each other.

Examples
--------
Examples:
>>> i = Itr(range(3))
>>> a, b = i.tee(2)
>>> list(a)
Expand Down
Loading