Skip to content

Commit 74c0a38

Browse files
committed
make ruff happy
1 parent ff7f848 commit 74c0a38

File tree

15 files changed

+37
-420
lines changed

15 files changed

+37
-420
lines changed

docs/user-guide/amor/amor-reduction.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"outputs": [],
2626
"source": [
2727
"import scipp as sc\n",
28-
"import sciline\n",
2928
"from ess import amor\n",
3029
"from ess.reflectometry.types import *\n",
3130
"from ess.amor.types import *"
@@ -354,8 +353,7 @@
354353
"mimetype": "text/x-python",
355354
"name": "python",
356355
"nbconvert_exporter": "python",
357-
"pygments_lexer": "ipython3",
358-
"version": "3.10.13"
356+
"pygments_lexer": "ipython3"
359357
}
360358
},
361359
"nbformat": 4,

docs/user-guide/amor/compare-to-eos.ipynb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"\n",
2424
"import scipp as sc\n",
2525
"import plopp as pp\n",
26-
"import sciline\n",
2726
"from ess import amor\n",
2827
"from ess.reflectometry.types import *\n",
2928
"from ess.amor.types import ChopperPhase"
@@ -137,7 +136,7 @@
137136
"outputs": [],
138137
"source": [
139138
"# PSI results\n",
140-
"for key, angle in mu.items():\n",
139+
"for key in mu:\n",
141140
" d = orsopy.fileio.load_orso(amor.data.amor_psi_software_result(key))[0].data\n",
142141
" y = sc.array(dims=['Q'], values=d[:, 1], variances=d[:, 2] ** 2)\n",
143142
" results['psi'][key] = sc.DataArray(\n",
@@ -162,7 +161,7 @@
162161
"source": [
163162
"fig, axs = plt.subplots(3, 2, figsize=(12, 12))\n",
164163
"\n",
165-
"for ax, (key, angle) in zip(axs.ravel(), mu.items()):\n",
164+
"for ax, (key, angle) in zip(axs.ravel(), mu.items(), strict=True):\n",
166165
" pp.plot(\n",
167166
" {\n",
168167
" facility: results[facility][key][results[facility][key].data > 0.0]\n",
@@ -196,9 +195,9 @@
196195
"source": [
197196
"fig, axs = plt.subplots(1, 2, figsize=(12, 4))\n",
198197
"\n",
199-
"for ax, (facility, res) in zip(axs.ravel(), results.items()):\n",
198+
"for ax, (facility, res) in zip(axs.ravel(), results.items(), strict=True):\n",
200199
" pp.plot(\n",
201-
" {k: v for k, v in list(res.items())[:4]}, # First 4 curves\n",
200+
" dict(list(res.items())[:4]), # First 4 curves\n",
202201
" ax=ax,\n",
203202
" norm='log',\n",
204203
" ls='solid',\n",

src/ess/amor/geometry.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
3-
from typing import Tuple
4-
53
import scipp as sc
64

75

@@ -30,7 +28,7 @@ class Detector:
3028

3129
def _pixel_coordinate_in_detector_system(
3230
pixelID: sc.Variable,
33-
) -> Tuple[sc.Variable, sc.Variable]:
31+
) -> tuple[sc.Variable, sc.Variable]:
3432
"""Determines beam travel distance inside the detector
3533
and the beam divergence angle from the detector number."""
3634
(bladeNr, bPixel) = (
@@ -55,7 +53,7 @@ def _pixel_coordinate_in_detector_system(
5553

5654
def pixel_coordinate_in_lab_frame(
5755
pixelID: sc.Variable, nu: sc.Variable
58-
) -> Tuple[sc.Variable, sc.Variable]:
56+
) -> tuple[sc.Variable, sc.Variable]:
5957
"""Computes spatial coordinates (lab reference frame), and the beam divergence
6058
angle for the detector pixel associated with `pixelID`"""
6159
distance_in_detector, divergence_angle = _pixel_coordinate_in_detector_system(

src/ess/amor/orso.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
33
"""ORSO utilities for Amor."""
44

5-
from typing import Optional
6-
75
import numpy as np
86
import scipp as sc
97
from orsopy.fileio import base as orso_base
@@ -81,9 +79,7 @@ def _extract_values_array(var: sc.Variable) -> np.ndarray:
8179
return var.values
8280

8381

84-
def _limits_of_coord(
85-
data: sc.DataArray, name: str
86-
) -> Optional[tuple[float, float, str]]:
82+
def _limits_of_coord(data: sc.DataArray, name: str) -> tuple[float, float, str] | None:
8783
if (coord := _get_coord(data, name)) is None:
8884
return None
8985
min_ = coord.min().value
@@ -92,7 +88,7 @@ def _limits_of_coord(
9288
return float(min_), float(max_), _ascii_unit(coord.unit)
9389

9490

95-
def _get_coord(data: sc.DataArray, name: str) -> Optional[sc.Variable]:
91+
def _get_coord(data: sc.DataArray, name: str) -> sc.Variable | None:
9692
if name in data.coords:
9793
return sc.DataArray(data=data.coords[name], masks=data.masks)
9894
if (data.bins is not None) and (name in data.bins.coords):

src/ess/amor/resolution.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ def sigma_Q(
145145
Combined resolution function.
146146
"""
147147
return sc.sqrt(
148-
angular_resolution**2
149-
+ wavelength_resolution**2
150-
+ sample_size_resolution**2
148+
angular_resolution**2 + wavelength_resolution**2 + sample_size_resolution**2
151149
).flatten(to="detector_number").max("detector_number") * sc.midpoints(q_bins)
152150

153151

src/ess/amor/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import scipp as sc
2-
32
from ess.reflectometry.types import (
43
DetectorRotation,
54
NormalizedIofQ,

src/ess/reflectometry/conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def add_coords(
130130
da = da.transform_coords(["theta", "wavelength", "Q"], graph=graph)
131131
da.coords["z_index"] = sc.arange(
132132
"row", 0, da.sizes["blade"] * da.sizes["wire"], unit=None
133-
).fold("row", sizes=dict(blade=da.sizes["blade"], wire=da.sizes["wire"]))
133+
).fold("row", sizes={dim: da.sizes[dim] for dim in ("blade", "wire")})
134134
da.coords["y_index"] = sc.arange("stripe", 0, da.sizes["stripe"], unit=None)
135135
return da
136136

src/ess/reflectometry/load.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Type, Union
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
23

34
import sciline
45
import scipp as sc
@@ -7,7 +8,7 @@
78
from .types import IdealReferenceIntensity, ReferenceFilePath
89

910

10-
def load_nx(group: Union[snx.Group, str], *paths: str):
11+
def load_nx(group: snx.Group | str, *paths: str):
1112
if isinstance(group, str):
1213
with snx.File(group) as group:
1314
yield from load_nx(group, *paths)
@@ -26,7 +27,7 @@ def load_nx(group: Union[snx.Group, str], *paths: str):
2627
# Remove when this function is exposed in essreduce
2728
def _unique_child_group(
2829
group: snx.Group,
29-
nx_class: Type[snx.NXobject],
30+
nx_class: type[snx.NXobject],
3031
) -> snx.Group:
3132
children = group[nx_class]
3233
if len(children) == 0:

0 commit comments

Comments
 (0)