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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ uv run prek install --prepare-hooks
uv run pytest -m "not slow" # fast suite
uv run pytest # everything
uv run ruff check src/ tests/
uv run ty check src/
uv run mkdocs serve
```

Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ replace them.
## Quality gates

All of these must pass before a pull request can be merged;
[`prek`](https://github.com/j178/prek) runs the first two automatically.
[`prek`](https://github.com/j178/prek) runs the lint, format and type checks automatically.

```bash
uv run ruff check src/ tests/ # lint
uv run ruff format --check src/ tests/
uv run ty check src/ # type check
uv run pytest -m "not slow" # fast test suite
uv run pytest # full suite, including slow tests
```
Expand All @@ -63,6 +64,6 @@ accuracy, not just the shapes.
## Code style

The project targets Python 3.11+ and is checked with `ruff` under a strict rule
set. Public functions carry type hints and Google-style docstrings without type
set and type-checked with [`ty`](https://github.com/astral-sh/ty). Public functions carry type hints and Google-style docstrings without type
annotations in the argument list. Keep lines within the configured limit and
prefer clear code over clever code.
7 changes: 7 additions & 0 deletions prek.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ hooks = [
repo = "https://github.com/astral-sh/uv-pre-commit"
rev = "0.8.14"
hooks = [{ id = "uv-lock" }]


[[repos]]
# Keep in sync with the ty pin in pyproject.toml.
repo = "https://github.com/astral-sh/ty-pre-commit"
rev = "v0.0.82"
hooks = [{ id = "ty" }]
28 changes: 8 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ dev = [
"prek>=0.2.6",
"ruff==0.16.5",
"cyclopts>=3.20",
"ty==0.0.82",
{ include-group = "test" },
]
interactive = [
Expand Down Expand Up @@ -269,25 +270,12 @@ convention = "google"
required-imports = ["from __future__ import annotations"]


[tool.pyright]
pythonVersion = "3.11"
[tool.ty.environment]
python-version = "3.11"

include = ["src/src_method/**/*.py"]
[tool.ty.analysis]
# Optional GPU dependency, imported lazily in `get_xp`.
allowed-unresolved-imports = ["cupy"]

exclude = ["test_*.py", "docs/**", "**/__pycache__"]

typeCheckingMode = "basic"
useLibraryCodeForTypes = true

reportGeneralTypeIssues = "information"
reportMissingImports = true
reportMissingTypeStubs = "warning"
reportImportCycles = "information"
reportPrivateUsage = "information"
reportPrivateImportUsage = "information"
reportUnnecessaryIsInstance = "information"
reportUnnecessaryCast = "information"
reportUnnecessaryComparison = "information"
reportUnnecessaryContains = "information"
reportUnnecessaryTypeIgnoreComment = "information"
reportMatchNotExhaustive = "information"
[tool.ty.src]
include = ["src/src_method"]
6 changes: 5 additions & 1 deletion src/src_method/utils/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
from numpy.typing import NDArray


def truncated_qr(matrix: NDArray, cutoff: float, xp: ModuleType = np) -> NDArray:
def truncated_qr(
matrix: NDArray[np.floating | np.complexfloating],
cutoff: float,
xp: ModuleType = np,
) -> NDArray[np.floating | np.complexfloating]:
"""QR with SVD-based rank truncation, returning only the isometry.

Decomposes ``matrix = Q @ R``, then truncates via SVD on R,
Expand Down
3 changes: 1 addition & 2 deletions src/src_method/utils/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ def setup_logging(default_level: str = "INFO") -> None:
"""
# Configure Python's standard logging
level_name = os.environ.get("LOG_LEVEL_SRC", default_level)
level = logging.getLevelName(level_name.upper())
logging.basicConfig(
level=level,
level=level_name.upper(),
format="%(message)s",
stream=sys.stdout,
)
Expand Down
27 changes: 27 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading