Skip to content

Commit 8e0cbdc

Browse files
committed
ignore spurious type errors with numpy 2.2
1 parent b3f93ea commit 8e0cbdc

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

src/stagpy/dimensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def make_dimensional(self, data: T, unit: str, scaling: Scaling) -> tuple[T, str
4343
if factor in phyvars.PREFIXES:
4444
scale *= 10 ** (-3 * (phyvars.PREFIXES.index(factor) + 1))
4545
unit = factor + unit
46-
return data * scale, unit
46+
return data * scale, unit # type: ignore
4747

4848
@cached_property
4949
def length(self) -> float:

src/stagpy/field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def plot_scalar(
213213
# interpolate at cell centers, this should be abstracted by field objects
214214
# via an "at_cell_centers" method or similar
215215
if fld.shape[0] > max(step.geom.nxtot, step.geom.nytot):
216-
fld = (fld[:-1] + fld[1:]) / 2
216+
fld: NDArray[np.float64] = (fld[:-1] + fld[1:]) / 2 # type: ignore
217217

218218
xmin, xmax = xmesh.min(), xmesh.max()
219219
ymin, ymax = ymesh.min(), ymesh.max()

src/stagpy/plates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def _write_trench_diagnostics(
284284

285285
# vphi at trenches
286286
vphi = step.fields["v2"].values[0, :, isurf, 0]
287-
vphi = (vphi[1:] + vphi[:-1]) / 2
287+
vphi: NDArray[np.float64] = (vphi[1:] + vphi[:-1]) / 2 # type: ignore
288288
v_trenches = vphi[itrenches]
289289

290290
if "age" in step.fields:

src/stagpy/processing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def ebalance(sdat: StagyyData) -> Tseries:
7878
ftop = sdat.tseries["ftop"].values * coefsurf
7979
fbot = sdat.tseries["fbot"].values
8080
radio = sdat.tseries["H_int"].values
81-
ebal = ftop[1:] - fbot[1:] + volume * (dtdt.values - radio[1:])
81+
ebal: NDArray[np.float64] = ftop[1:] - fbot[1:] + volume * (dtdt.values - radio[1:]) # type: ignore
8282
return Tseries(ebal, dtdt.time, Vart("Energy balance", r"$\mathrm{Nu}$", "1"))
8383

8484

@@ -126,7 +126,7 @@ def _scale_prof(
126126
return rprof
127127
if rad is None:
128128
rad = step.rprofs.centers
129-
return rprof * (2 * rad / (rtop + rbot)) ** 2
129+
return rprof * (2 * rad / (rtop + rbot)) ** 2 # type: ignore
130130

131131

132132
def diff_prof(step: Step) -> Rprof:
@@ -234,7 +234,7 @@ def energy_prof(step: Step) -> Rprof:
234234
diff_p = diffs_prof(step)
235235
adv_p = advts_prof(step)
236236
return Rprof(
237-
diff_p.values + np.append(adv_p.values, 0),
237+
diff_p.values + np.append(adv_p.values, 0), # type: ignore
238238
diff_p.rad,
239239
Varr("Total heat flux", "Heat flux", "W/m2"),
240240
)

src/stagpy/rprof.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import typing
66

77
import matplotlib.pyplot as plt
8+
import numpy as np
89

910
from . import _helpers
1011
from .config import Config
@@ -13,6 +14,8 @@
1314
if typing.TYPE_CHECKING:
1415
from collections.abc import Sequence
1516

17+
from numpy.typing import NDArray
18+
1619
from .step import Rprofs, Step
1720

1821

@@ -48,7 +51,7 @@ def plot_rprofs(
4851
rad = rpf.rad
4952
meta = rpf.meta
5053
if conf.rprof.depth:
51-
rad = rprofs.bounds[1] - rad
54+
rad: NDArray[np.float64] = rprofs.bounds[1] - rad # type: ignore
5255
axes[iplt].plot(rprof, rad, conf.rprof.style, label=meta.description)
5356
if xlabel is None:
5457
xlabel = meta.kind

src/stagpy/step.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def t_walls(self) -> NDArray[np.float64]:
152152
@cached_property
153153
def t_centers(self) -> NDArray[np.float64]:
154154
"""Position of FV centers along x/theta."""
155-
return (self.t_walls[:-1] + self.t_walls[1:]) / 2
155+
return (self.t_walls[:-1] + self.t_walls[1:]) / 2 # type: ignore
156156

157157
@cached_property
158158
def p_walls(self) -> NDArray[np.float64]:
@@ -174,7 +174,7 @@ def p_walls(self) -> NDArray[np.float64]:
174174
@cached_property
175175
def p_centers(self) -> NDArray[np.float64]:
176176
"""Position of FV centers along y/phi."""
177-
return (self.p_walls[:-1] + self.p_walls[1:]) / 2
177+
return (self.p_walls[:-1] + self.p_walls[1:]) / 2 # type: ignore
178178

179179
@property
180180
def z_walls(self) -> NDArray[np.float64]:
@@ -516,7 +516,7 @@ def stepstr(self) -> str:
516516
@cached_property
517517
def centers(self) -> NDArray[np.float64]:
518518
"""Radial position of cell centers."""
519-
return self._rprofs["r"].to_numpy() + self.bounds[0]
519+
return self._rprofs["r"].to_numpy() + self.bounds[0] # type: ignore
520520

521521
@cached_property
522522
def walls(self) -> NDArray[np.float64]:
@@ -528,9 +528,9 @@ def walls(self) -> NDArray[np.float64]:
528528
# assume walls are mid-way between T-nodes
529529
# could be T-nodes at center between walls
530530
centers = self.centers
531-
walls = (centers[:-1] + centers[1:]) / 2
531+
walls: NDArray[np.float64] = (centers[:-1] + centers[1:]) / 2 # type: ignore
532532
walls = np.insert(walls, 0, rbot)
533-
walls = np.append(walls, rtop)
533+
walls: NDArray[np.float64] = np.append(walls, rtop) # type: ignore
534534
return walls
535535

536536
@cached_property

0 commit comments

Comments
 (0)