Skip to content

Commit 99a836f

Browse files
authored
Merge branch 'main' into pre-commit-ci-update-config
2 parents 626a4a7 + d25e7e7 commit 99a836f

26 files changed

+133
-205
lines changed

.github/workflows/coverage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
- name: Set up Python ${{ matrix.python-version }}
1212
uses: actions/setup-python@v5
1313
with:
14-
python-version: 3.11
15-
- name: Install dependencies
16-
run: pip install nox
14+
python-version: 3.13
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v6
1717
- name: Test with nox
18-
run: nox -e coverage
18+
run: uv run --group nox nox -e coverage
1919
- name: Upload coverage to Codecov
2020
uses: codecov/codecov-action@v4

.github/workflows/matchers/pytest.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/nox.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
platform: [ubuntu-latest, macos-latest, windows-latest]
15-
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
python-version: ["3.11", "3.12", "3.13"]
1616

1717
steps:
1818
- uses: actions/checkout@v4
1919
- name: Set up Python ${{ matrix.python-version }}
2020
uses: actions/setup-python@v5
2121
with:
2222
python-version: ${{ matrix.python-version }}
23-
- name: Register Python problem matcher
24-
run: echo "::add-matcher::.github/workflows/matchers/pytest.json"
25-
- name: Install dependencies
26-
run: pip install nox pytest-github-actions-annotate-failures
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v6
2725
- name: Test with nox using minimal dependencies
28-
run: nox -e "pytest-${{ matrix.python-version }}(all_deps=False)"
26+
run: uv run --group nox nox -e "pytest_min_deps-${{ matrix.python-version }}"
2927
- name: Test with nox with all dependencies
30-
run: nox -e "pytest-${{ matrix.python-version }}(all_deps=True)"
28+
run: uv run --group nox nox -e "pytest_all_deps-${{ matrix.python-version }}"

.github/workflows/typeguard.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
- name: Set up Python ${{ matrix.python-version }}
1313
uses: actions/setup-python@v5
1414
with:
15-
python-version: "3.11"
16-
- name: Install dependencies
17-
run: pip install nox
15+
python-version: "3.13"
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v6
1818
- name: Test with nox
19-
run: nox -e pytest_typeguard
19+
run: uv run --group nox nox -e pytest_typeguard

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ jupyter labextension install @pyviz/jupyterlab_pyviz
160160

161161
## :wrench: Development
162162

163-
Clone the repository and run `pip install -e ".[notebook,testing,other]"` to add a link to the cloned repo into your Python path:
163+
Clone the repository and run `pip install -e ".[notebook,test,other]"` to add a link to the cloned repo into your Python path:
164164

165165
```bash
166166
git clone git@github.com:python-adaptive/adaptive.git
167167
cd adaptive
168-
pip install -e ".[notebook,testing,other]"
168+
pip install -e ".[notebook,test,other]"
169169
```
170170

171171
We recommend using a Conda environment or a virtualenv for package management during Adaptive development.

adaptive/learner/average_learner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

3+
from collections.abc import Callable
34
from math import sqrt
4-
from typing import Callable
55

66
import cloudpickle
77
import numpy as np

adaptive/learner/average_learner1D.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import math
44
import sys
55
from collections import defaultdict
6-
from collections.abc import Iterable, Sequence
6+
from collections.abc import Callable, Iterable, Sequence
77
from copy import deepcopy
88
from math import hypot
9-
from typing import Callable
109

1110
import numpy as np
1211
import scipy.stats

adaptive/learner/balancing_learner.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from __future__ import annotations
22

33
import itertools
4-
import sys
54
from collections import defaultdict
6-
from collections.abc import Iterable, Sequence
5+
from collections.abc import Callable, Iterable, Sequence
76
from contextlib import suppress
87
from functools import partial
98
from operator import itemgetter
10-
from typing import Any, Callable, Union, cast
9+
from typing import Any, Literal, TypeAlias, cast
1110

1211
import numpy as np
1312

@@ -16,13 +15,6 @@
1615
from adaptive.types import Int, Real
1716
from adaptive.utils import cache_latest, named_product, restore
1817

19-
if sys.version_info >= (3, 10):
20-
from typing import TypeAlias
21-
else:
22-
from typing_extensions import TypeAlias
23-
24-
from typing import Literal
25-
2618
try:
2719
import pandas
2820

@@ -38,11 +30,9 @@ def dispatch(child_functions: list[Callable], arg: Any) -> Any:
3830

3931
STRATEGY_TYPE: TypeAlias = Literal["loss_improvements", "loss", "npoints", "cycle"]
4032

41-
CDIMS_TYPE: TypeAlias = Union[
42-
Sequence[dict[str, Any]],
43-
tuple[Sequence[str], Sequence[tuple[Any, ...]]],
44-
None,
45-
]
33+
CDIMS_TYPE: TypeAlias = (
34+
Sequence[dict[str, Any]] | tuple[Sequence[str], Sequence[tuple[Any, ...]]] | None
35+
)
4636

4737

4838
class BalancingLearner(BaseLearner):

adaptive/learner/base_learner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
22

33
import abc
4+
from collections.abc import Callable
45
from contextlib import suppress
5-
from typing import TYPE_CHECKING, Any, Callable, TypeVar
6+
from typing import TYPE_CHECKING, Any, TypeVar
67

78
import cloudpickle
89

adaptive/learner/data_saver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import functools
44
from collections import OrderedDict
5-
from typing import Any, Callable
5+
from collections.abc import Callable
6+
from typing import Any
67

78
from adaptive.learner.base_learner import BaseLearner, LearnerType
89
from adaptive.utils import copy_docstring_from

adaptive/learner/integrator_learner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
import sys
55
from collections import defaultdict
6+
from collections.abc import Callable
67
from math import sqrt
78
from operator import attrgetter
8-
from typing import TYPE_CHECKING, Callable
9+
from typing import TYPE_CHECKING
910

1011
import cloudpickle
1112
import numpy as np

adaptive/learner/learner1D.py

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import collections.abc
44
import itertools
55
import math
6-
import sys
7-
from collections.abc import Sequence
6+
from collections.abc import Callable, Sequence
87
from copy import copy, deepcopy
9-
from typing import TYPE_CHECKING, Any, Callable, Optional, Union
8+
from typing import TYPE_CHECKING, Any, TypeAlias
109

1110
import cloudpickle
1211
import numpy as np
@@ -24,12 +23,6 @@
2423
partial_function_from_dataframe,
2524
)
2625

27-
if sys.version_info >= (3, 10):
28-
from typing import TypeAlias
29-
else:
30-
from typing_extensions import TypeAlias
31-
32-
3326
try:
3427
import pandas
3528

@@ -42,28 +35,21 @@
4235
# -- types --
4336

4437
# Commonly used types
45-
Interval: TypeAlias = Union[tuple[float, float], tuple[float, float, int]]
46-
NeighborsType: TypeAlias = SortedDict[float, list[Optional[float]]]
38+
Interval: TypeAlias = tuple[float, float] | tuple[float, float, int]
39+
NeighborsType: TypeAlias = SortedDict[float, list[float | None]]
4740

4841
# Types for loss_per_interval functions
4942
XsType0: TypeAlias = tuple[float, float]
50-
YsType0: TypeAlias = Union[tuple[float, float], tuple[np.ndarray, np.ndarray]]
51-
XsType1: TypeAlias = tuple[
52-
Optional[float], Optional[float], Optional[float], Optional[float]
53-
]
54-
YsType1: TypeAlias = Union[
55-
tuple[Optional[float], Optional[float], Optional[float], Optional[float]],
56-
tuple[
57-
Optional[np.ndarray],
58-
Optional[np.ndarray],
59-
Optional[np.ndarray],
60-
Optional[np.ndarray],
61-
],
62-
]
63-
XsTypeN: TypeAlias = tuple[Optional[float], ...]
64-
YsTypeN: TypeAlias = Union[
65-
tuple[Optional[float], ...], tuple[Optional[np.ndarray], ...]
66-
]
43+
YsType0: TypeAlias = tuple[float, float] | tuple[np.ndarray, np.ndarray]
44+
XsType1: TypeAlias = tuple[float | None, float | None, float | None, float | None]
45+
YsType1: TypeAlias = (
46+
tuple[float | None, float | None, float | None, float | None]
47+
| tuple[
48+
np.ndarray | None, np.ndarray | None, np.ndarray | None, np.ndarray | None
49+
]
50+
)
51+
XsTypeN: TypeAlias = tuple[float | None, ...]
52+
YsTypeN: TypeAlias = tuple[float | None, ...] | tuple[np.ndarray | None, ...]
6753

6854

6955
__all__ = [
@@ -598,7 +584,7 @@ def tell(self, x: float, y: Float | Sequence[Float] | np.ndarray) -> None:
598584
)
599585

600586
# either it is a float/int, if not, try casting to a np.array
601-
if not isinstance(y, (float, int)):
587+
if not isinstance(y, float | int):
602588
y = np.asarray(y, dtype=float)
603589

604590
# Add point to the real data dict

adaptive/learner/learner2D.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import itertools
44
import warnings
55
from collections import OrderedDict
6-
from collections.abc import Iterable
6+
from collections.abc import Callable, Iterable
77
from copy import copy
88
from math import sqrt
9-
from typing import Callable
109

1110
import cloudpickle
1211
import numpy as np
1312
from scipy import interpolate
14-
from scipy.interpolate import LinearNDInterpolator
13+
from scipy.interpolate import CloughTocher2DInterpolator, LinearNDInterpolator
1514

1615
from adaptive.learner.base_learner import BaseLearner
1716
from adaptive.learner.triangulation import simplex_volume_in_embedding
@@ -49,9 +48,7 @@ def deviations(ip: LinearNDInterpolator) -> list[np.ndarray]:
4948
The deviation per triangle.
5049
"""
5150
values = ip.values / (np.ptp(ip.values, axis=0).max() or 1)
52-
gradients = interpolate.interpnd.estimate_gradients_2d_global(
53-
ip.tri, values, tol=1e-6
54-
)
51+
gradients = CloughTocher2DInterpolator(ip.tri, values, tol=1e-6).grad
5552

5653
simplices = ip.tri.simplices
5754
p = ip.tri.points[simplices]

adaptive/learner/sequence_learner.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from __future__ import annotations
22

3-
import sys
43
from copy import copy
5-
from typing import TYPE_CHECKING, Any
4+
from typing import TYPE_CHECKING, Any, TypeAlias
65

76
import cloudpickle
87
from sortedcontainers import SortedDict, SortedSet
@@ -16,8 +15,7 @@
1615
)
1716

1817
if TYPE_CHECKING:
19-
from collections.abc import Sequence
20-
from typing import Callable
18+
from collections.abc import Callable, Sequence
2119

2220
try:
2321
import pandas
@@ -27,10 +25,6 @@
2725
except ModuleNotFoundError:
2826
with_pandas = False
2927

30-
if sys.version_info >= (3, 10):
31-
from typing import TypeAlias
32-
else:
33-
from typing_extensions import TypeAlias
3428

3529
PointType: TypeAlias = tuple[Int, Any]
3630

0 commit comments

Comments
 (0)