Skip to content

Commit 6a71510

Browse files
authored
Dev deps (#330)
* Replace black with ruff format and format doc string code * Fix some formatting deltas and exclude some rules that apply more broadly than before. * Remove hard coded black from workflow * Add some more package bounds. Add test for oldest package version. * Locally verified 1.24, wouldn't be too hard to update to support older if desired * Actually add github action for testing oldest * Bad default glob * Uv really means it when they say oldest. * Try using uv pip interface without venv * Another round. Worked locally * Another minimum * Remove final black reference * Try updating broken link * Update pytest instructions
1 parent 2c77248 commit 6a71510

19 files changed

+491
-424
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This should mirror regression tests. Ideally we find a way in the future to fold the two together
2+
3+
name: Test Oldest Dependencies
4+
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
env:
12+
UV_SYSTEM_PYTHON: 1
13+
14+
jobs:
15+
test-oldest:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
# Use uv since it has easy lowest resolution
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v3
25+
with:
26+
enable-cache: true
27+
cache-dependency-glob: "**/pyproject.toml"
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.9' # Find a way to globally define our minimum python once
33+
34+
- name: Install dependencies with minimum versions
35+
run: |
36+
uv sync --resolution lowest-direct --extra dev
37+
38+
- name: Run tests
39+
run: |
40+
uv run --resolution lowest-direct pytest ./tests

.github/workflows/regression-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ jobs:
3434
run: |
3535
python -m pip install --upgrade coverage coveralls sphinx_rtd_theme
3636
pip install ".[dev]"
37-
- name: Check auto-formatters
38-
run: |
39-
black --check .
4037
- name: Run tests
4138
run: |
4239
coverage run --source pyttb -m pytest tests/

.pre-commit-config.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.0.284
3+
rev: v0.7.2
44
hooks:
55
- id: ruff
66
args: [ --fix, --exit-non-zero-on-fix ]
7-
- repo: https://github.com/psf/black
8-
rev: 24.1.1
9-
hooks:
10-
- id: black
11-
language_version: python
7+
- id: ruff-format
128
- repo: https://github.com/kynan/nbstripout
13-
rev: 0.6.1
9+
rev: 0.8.0
1410
hooks:
1511
- id: nbstripout
1612
args: [

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
# v1.3.3 (2022-07-11)
136136
- Fixed indexing bug in `tensor.mttkrp` (Issue #35, PR #36)
137137
- Updated LICENSE to compliant format (Issue #33 , PR #34)
138-
- Now using [coveralls.io](https://coveralls.io/github/sandialabs/pyttb) for coverage reporting
138+
- Now using [coveralls.io](https://coveralls.io/github/sandialabs/pyttb?branch=main) for coverage reporting
139139
- Now using [readthedocs.io](https://pyttb.readthedocs.io/en/latest/) for documentation
140140

141141
# v1.3.2 (2022-07-06)

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ current or filing a new [issue](https://github.com/sandialabs/pyttb/issues).
3939
1. Run autoformatters and linting from root of project (they will change your code)
4040
```commandline
4141
ruff check . --fix
42-
black .
42+
ruff format
4343
```
4444
1. Ruff's `--fix` won't necessarily address everything and may point out issues that need manual attention
4545
1. [We](./.pre-commit-config.yaml) optionally support [pre-commit hooks](https://pre-commit.com/) for this
@@ -52,15 +52,15 @@ current or filing a new [issue](https://github.com/sandialabs/pyttb/issues).
5252
1. Run tests (at desired fidelity)
5353
1. Just doctests (enabled by default)
5454
```commandline
55-
pytest
55+
pytest .
5656
```
5757
1. Functional tests
5858
```commandline
59-
pytest .
59+
pytest tests
6060
```
6161
1. With coverage
6262
```commandline
63-
pytest . --cov=pyttb --cov-report=term-missing
63+
pytest tests --cov=pyttb --cov-report=term-missing
6464
```
6565
6666
1. (Optionally) Building documentation and tutorials

pyproject.toml

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ readme = "README.md"
1010
requires-python = ">=3.9"
1111

1212
dependencies = [
13-
"numpy",
14-
"numpy_groupies",
15-
"scipy",
16-
"matplotlib",
13+
"numpy<3.0,>=1.24",
14+
"numpy_groupies>0.11",
15+
"scipy>1.9",
16+
"matplotlib>3.7",
1717
]
1818

1919
classifiers = [
@@ -32,18 +32,19 @@ documentation = "https://pyttb.readthedocs.io"
3232

3333
[project.optional-dependencies]
3434
dev = [
35-
"black[jupyter]",
36-
"mypy",
37-
"nbstripout",
38-
"pytest",
39-
"pytest-cov",
40-
"ruff==0.0.284",
41-
"pre-commit",
35+
"mypy>=1.10,<1.14.0",
36+
# Also in pre-commit
37+
"nbstripout>=0.8,<0.9",
38+
"pytest>8.0",
39+
"pytest-cov>5.0",
40+
# Also in pre-commit
41+
"ruff>=0.7,<0.8",
42+
"pre-commit>=4.0,<5.0",
4243
]
4344
doc = [
4445
"sphinx >= 4.0",
45-
"sphinx_rtd_theme",
46-
"myst-nb",
46+
"sphinx_rtd_theme>2.0",
47+
"myst-nb>1.0",
4748
]
4849
profiling = [
4950
"gprof2dot",
@@ -65,7 +66,7 @@ version = {attr = "pyttb.__version__"}
6566
requires = ["setuptools>=61.0", "numpy", "numpy_groupies", "scipy", "wheel"]
6667
build-backend = "setuptools.build_meta"
6768

68-
[tool.ruff]
69+
[tool.ruff.lint]
6970
select = ["E", "F", "PL", "W", "I", "N", "NPY", "RUF", "B"]
7071
ignore = [
7172
# Ignored in conversion to ruff since not previously enforced
@@ -83,13 +84,18 @@ ignore = [
8384
# There is ongoing discussion about logging/warning etc
8485
"B028",
8586
]
86-
[tool.ruff.per-file-ignores]
87+
[tool.ruff.lint.per-file-ignores]
8788
# See see https://github.com/astral-sh/ruff/issues/3172 for details on this becoming simpler
8889

8990
# Everything but I, F (to catch import mess and potential logic errors)
9091
"tests/**.py" = ["E", "PL", "W", "N", "NPY", "RUF", "B"]
9192
# Ignore everything for now
9293
"docs/**.py" = ["E", "F", "PL", "W", "I", "N", "NPY", "RUF", "B"]
94+
"docs/**.ipynb" = ["E", "F", "PL", "W", "I", "N", "NPY", "RUF", "B"]
95+
"profiling/**.ipynb" = ["E", "F", "PL", "W", "I", "N", "NPY", "RUF", "B"]
96+
97+
[tool.ruff.format]
98+
docstring-code-format = true
9399

94100
[tool.mypy]
95101
warn_unused_configs = true

pyttb/cp_apr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ def tt_cp_apr_pqnr( # noqa: PLR0912,PLR0913,PLR0915
11381138

11391139

11401140
@overload
1141-
def tt_calcpi_prowsubprob( # noqa: PLR0913
1141+
def tt_calcpi_prowsubprob(
11421142
Data: ttb.sptensor,
11431143
Model: ttb.ktensor,
11441144
rank: int,
@@ -1150,7 +1150,7 @@ def tt_calcpi_prowsubprob( # noqa: PLR0913
11501150

11511151

11521152
@overload
1153-
def tt_calcpi_prowsubprob( # noqa: PLR0913
1153+
def tt_calcpi_prowsubprob(
11541154
Data: ttb.tensor,
11551155
Model: ttb.ktensor,
11561156
rank: int,

pyttb/gcp/fg_est.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
@overload
20-
def estimate( # noqa: PLR0913
20+
def estimate(
2121
model: ttb.ktensor,
2222
data_subs: np.ndarray,
2323
data_vals: np.ndarray,
@@ -30,7 +30,7 @@ def estimate( # noqa: PLR0913
3030

3131

3232
@overload
33-
def estimate( # noqa: PLR0913
33+
def estimate(
3434
model: ttb.ktensor,
3535
data_subs: np.ndarray,
3636
data_vals: np.ndarray,
@@ -43,7 +43,7 @@ def estimate( # noqa: PLR0913
4343

4444

4545
@overload
46-
def estimate( # noqa: PLR0913
46+
def estimate(
4747
model: ttb.ktensor,
4848
data_subs: np.ndarray,
4949
data_vals: np.ndarray,

pyttb/hosvd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def hosvd( # noqa: PLR0912,PLR0913,PLR0915
4646
4747
Example
4848
-------
49-
>>> data = np.array([[29, 39.], [63., 85.]])
49+
>>> data = np.array([[29, 39.0], [63.0, 85.0]])
5050
>>> tol = 1e-4
5151
>>> disable_printing = -1
5252
>>> tensorInstance = ttb.tensor(data)

pyttb/khatrirao.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def khatrirao(*matrices: np.ndarray, reverse: bool = False) -> np.ndarray:
2525
2626
Examples
2727
--------
28-
>>> A = np.random.normal(size=(5,2))
29-
>>> B = np.random.normal(size=(5,2))
30-
>>> _ = khatrirao(A,B) #<-- Khatri-Rao of A and B
31-
>>> _ = khatrirao(B,A,reverse=True) #<-- same thing as above
32-
>>> _ = khatrirao(A,A,B) #<-- passing multiple items
33-
>>> _ = khatrirao(B,A,A,reverse = True) #<-- same as above
34-
>>> _ = khatrirao(*[A,A,B]) #<-- passing a list via unpacking items
28+
>>> A = np.random.normal(size=(5, 2))
29+
>>> B = np.random.normal(size=(5, 2))
30+
>>> _ = khatrirao(A, B) # <-- Khatri-Rao of A and B
31+
>>> _ = khatrirao(B, A, reverse=True) # <-- same thing as above
32+
>>> _ = khatrirao(A, A, B) # <-- passing multiple items
33+
>>> _ = khatrirao(B, A, A, reverse=True) # <-- same as above
34+
>>> _ = khatrirao(*[A, A, B]) # <-- passing a list via unpacking items
3535
"""
3636
# Determine if list of matrices of multiple matrix arguments
3737
if len(matrices) == 1 and isinstance(matrices[0], list):

0 commit comments

Comments
 (0)