Skip to content

Commit 7ae1d2a

Browse files
authored
Merge pull request #541 from alan-turing-institute/540-add-target-version-to-ruff
Add target-version to ruff config to extend lints (#540)
2 parents a27c34c + b3d4e18 commit 7ae1d2a

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

autoemulate/experimental/data/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def _convert_to_dataset(
2929
if isinstance(y, np.ndarray):
3030
y = torch.tensor(y, dtype=torch.float32)
3131

32-
if isinstance(x, (torch.Tensor, np.ndarray)) and isinstance(
33-
y, (torch.Tensor, np.ndarray)
32+
if isinstance(x, torch.Tensor | np.ndarray) and isinstance(
33+
y, torch.Tensor | np.ndarray
3434
):
3535
dataset = TensorDataset(x, y)
36-
elif isinstance(x, (torch.Tensor, np.ndarray)) and y is None:
36+
elif isinstance(x, torch.Tensor | np.ndarray) and y is None:
3737
dataset = TensorDataset(x)
3838
elif isinstance(x, Dataset) and y is None:
3939
dataset = x

autoemulate/experimental/emulators/lightgbm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _fit(self, x: TensorLike, y: TensorLike):
104104
def _predict(self, x: TensorLike) -> OutputLike:
105105
"""Predicts the output of the emulator for a given input."""
106106
y_pred = self.model_.predict(x)
107-
assert not isinstance(y_pred, (spmatrix, list))
107+
assert not isinstance(y_pred, spmatrix | list)
108108
_, y = self._convert_to_tensors(x, y_pred)
109109
return y
110110

autoemulate/experimental/emulators/neural_processes/conditional_neural_process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def cnp_collate_fn(batch, device: DeviceLike | None = None):
105105
as we don't do layernorm or attention, but we should modify cnp etc. to handle this
106106
better.
107107
"""
108-
X, y = zip(*batch)
108+
X, y = zip(*batch, strict=False)
109109
device = get_torch_device(device)
110110

111111
# Get the maximum number of context and target points in the batch
@@ -123,7 +123,7 @@ def cnp_collate_fn(batch, device: DeviceLike | None = None):
123123
target_mask = torch.zeros(len(batch), max_target, dtype=torch.bool)
124124

125125
# Fill in the batched tensors
126-
for i, (x, yi) in enumerate(zip(X, y)):
126+
for i, (x, yi) in enumerate(zip(X, y, strict=False)):
127127
n_context = x["x_context"].shape[0]
128128
n_target = x["x_target"].shape[0]
129129

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ include = ["autoemulate/experimental/*", "tests/experimental/*"]
6868
src = ["autoemulate/"]
6969
line-length = 88
7070
include = ["autoemulate/experimental/**/*.py", "tests/experimental/**/*.py"]
71+
target-version = "py310"
7172

7273
[tool.ruff.format]
7374
docstring-code-format = true

0 commit comments

Comments
 (0)