Skip to content

Commit

Permalink
fix numpy 2.0 deprecations by ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
scottstanie committed Oct 14, 2024
1 parent 7c28697 commit 26a8217
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ select = [
"I", # isort
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"NPY201", # numpy 2.0 depgrcations
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # Pylint
Expand Down
4 changes: 2 additions & 2 deletions src/dolphin/atmosphere/weather_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ def _get_ztd(self):
# Get the integrated ZTD
wet_total, hydro_total = np.zeros(wet.shape), np.zeros(hydro.shape)
for level in range(wet.shape[2]):
wet_total[..., level] = 1e-6 * np.trapz(
wet_total[..., level] = 1e-6 * np.trapezoid(
wet[..., level:], x=self._zs[level:], axis=2
)
hydro_total[..., level] = 1e-6 * np.trapz(
hydro_total[..., level] = 1e-6 * np.trapezoid(
hydro[..., level:], x=self._zs[level:], axis=2
)
self._hydrostatic_ztd = hydro_total
Expand Down
4 changes: 2 additions & 2 deletions src/dolphin/goldstein.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def goldstein(
phase: NDArray[np.complex64] | NDArray[np.float_], alpha: float, psize: int = 32
phase: NDArray[np.complex64] | NDArray[np.float64], alpha: float, psize: int = 32
) -> np.ndarray:
"""Apply the Goldstein adaptive filter to the given data.
Expand Down Expand Up @@ -54,7 +54,7 @@ def make_weight(nxp: int, nyp: int) -> np.ndarray:
return weight

def patch_goldstein_filter(
data: NDArray[np.complex64], weight: NDArray[np.float_], psize: int
data: NDArray[np.complex64], weight: NDArray[np.float64], psize: int
) -> np.ndarray:
"""Apply the filter to a single patch of data.
Expand Down
2 changes: 1 addition & 1 deletion tests/make_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _add_complex_type(h5_root_group):
if "complex64" in h5_root_group:
return
ctype = h5py.h5t.py_create(np.complex64)
ctype.commit(h5_root_group.id, np.string_("complex64"))
ctype.commit(h5_root_group.id, np.bytes_("complex64"))


def create_test_nc(
Expand Down
8 changes: 4 additions & 4 deletions tests/test_unwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ def ifg_file_list(self, tmp_path, slc_stack, slc_date_list):
from dolphin import io
from dolphin.phase_link import simulate

slc_stack = np.exp(
1j * simulate.make_defo_stack((20, 100, 200), sigma=1)
).astype("complex64")
slc_stack = np.exp(1j * simulate.make_defo_stack((20, 30, 40), sigma=1)).astype(
"complex64"
)
ifg_stack = slc_stack[1:] * slc_stack[[0]].conj()
# Write to a file
d = tmp_path / "gtiff"
Expand Down Expand Up @@ -374,7 +374,7 @@ def test_unwrap_whirlwind(self, tmp_path, raster_100_by_200, corr_raster):
corr_filename=corr_raster,
unw_filename=unw_filename,
unwrap_options=unwrap_options,
nlooks=3,
nlooks=1,
)
assert out_path.exists()
assert conncomp_path.exists()
Expand Down

0 comments on commit 26a8217

Please sign in to comment.