Skip to content

Commit 5c6d08c

Browse files
authored
Fixes following numpy 2 (#365)
1 parent 2bc6b38 commit 5c6d08c

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

pysteps/blending/steps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ def worker(j):
10981098
neginf=zerovalue,
10991099
)
11001100
# Put back the mask
1101-
R_f_ip_recomp[domain_mask] = np.NaN
1101+
R_f_ip_recomp[domain_mask] = np.nan
11021102
extrap_kwargs["displacement_prev"] = D[j]
11031103
R_f_ep_recomp_, D[j] = extrapolator(
11041104
R_f_ip_recomp,
@@ -1131,7 +1131,7 @@ def worker(j):
11311131
neginf=np.nanmin(R_f_ip),
11321132
)
11331133
for i in range(n_cascade_levels):
1134-
R_f_ep[i][temp_mask] = np.NaN
1134+
R_f_ep[i][temp_mask] = np.nan
11351135
# B. Noise
11361136
Yn_ip_recomp = blending.utils.recompose_cascade(
11371137
combined_cascade=Yn_ip,
@@ -1182,7 +1182,7 @@ def worker(j):
11821182
extrap_kwargs_pb["displacement_prev"] = D_pb[j]
11831183
# Apply the domain mask to the extrapolation component
11841184
R_ = precip.copy()
1185-
R_[domain_mask] = np.NaN
1185+
R_[domain_mask] = np.nan
11861186
R_pm_ep_, D_pb[j] = extrapolator(
11871187
R_,
11881188
velocity_blended,

pysteps/feature/shitomasi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def detection(
149149

150150
# convert to 8-bit
151151
input_image = np.ndarray.astype(input_image, "uint8")
152-
mask = (-1 * mask + 1).astype("uint8")
152+
mask = ~mask & 1
153153

154154
params = dict(
155155
maxCorners=max_num_features if max_num_features is not None else max_corners,

pysteps/io/importers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,15 +810,15 @@ def import_knmi_hdf5(filename, qty="ACRR", accutime=5.0, pixelsize=1000.0, **kwa
810810
# the no data value. The precision of the data is two decimals (0.01 mm).
811811
if qty == "ACRR":
812812
precip = np.where(
813-
precip_intermediate == 65535, np.NaN, precip_intermediate / 100.0
813+
precip_intermediate == 65535, np.nan, precip_intermediate / 100.0
814814
)
815815

816816
# In case reflectivities are imported, the no data value is 255. Values are
817817
# saved as integers. The reflectivities are not directly saved in dBZ, but
818818
# as: dBZ = 0.5 * pixel_value - 32.0 (this used to be 31.5).
819819
if qty == "DBZH":
820820
precip = np.where(
821-
precip_intermediate == 255, np.NaN, precip_intermediate * 0.5 - 32.0
821+
precip_intermediate == 255, np.nan, precip_intermediate * 0.5 - 32.0
822822
)
823823

824824
if precip is None:
@@ -1366,9 +1366,9 @@ def import_odim_hdf5(filename, qty="RATE", **kwargs):
13661366
mask = np.logical_and(~mask_u, ~mask_n)
13671367
quality = np.empty(arr.shape) # , dtype=float)
13681368
quality[mask] = arr[mask] * gain + offset
1369-
quality[~mask] = (
1370-
np.nan
1371-
) # a qui -----------------------------
1369+
quality[
1370+
~mask
1371+
] = np.nan # a qui -----------------------------
13721372

13731373
if precip is None:
13741374
raise IOError("requested quantity %s not found" % qty)

pysteps/tests/test_io_nowcast_importers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
[(precip, metadata), (np.zeros_like(precip), metadata)],
1919
)
2020
def test_import_netcdf(precip, metadata, tmp_path):
21+
22+
pytest.importorskip("pyproj")
23+
2124
field_shape = (precip.shape[1], precip.shape[2])
2225
startdate = metadata["timestamps"][-1]
2326
timestep = metadata["accutime"]

pysteps/tests/test_nowcasts_linda.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ def test_linda_wrong_inputs():
144144

145145
def test_linda_callback(tmp_path):
146146
"""Test LINDA callback functionality to export the output as a netcdf."""
147+
148+
pytest.importorskip("skimage")
149+
147150
n_ens_members = 2
148151
n_timesteps = 3
149152

0 commit comments

Comments
 (0)