Skip to content

Commit

Permalink
support numpy 2
Browse files Browse the repository at this point in the history
  • Loading branch information
d-chambers committed Sep 13, 2024
1 parent 8fa6680 commit b372aea
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dascore/core/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def __str__(self):

__repr__ = __str__

def __array__(self):
def __array__(self, dtype=None, copy=False):
"""Numpy method for getting array data with `np.array(coord)`."""
return self.data

Expand Down
2 changes: 1 addition & 1 deletion dascore/io/dashdf5/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class ProdMLPatchAttrs(dc.PatchAttrs):
"""Patch attrs for ProdML."""

pulse_width: float = np.NAN
pulse_width: float = np.nan
pulse_width_units: UnitQuantity | None = None
gauge_length: float = np.nan
gauge_length_units: UnitQuantity | None = None
Expand Down
2 changes: 1 addition & 1 deletion dascore/io/prodml/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class ProdMLPatchAttrs(dc.PatchAttrs):
"""Patch attrs for ProdML."""

pulse_width: float = np.NAN
pulse_width: float = np.nan
pulse_width_units: UnitQuantity | None = None
gauge_length: float = np.nan
gauge_length_units: UnitQuantity | None = None
Expand Down
2 changes: 1 addition & 1 deletion dascore/io/xml_binary/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class BinaryPatchAttrs(dc.PatchAttrs):
"""Patch attrs for Binary."""

pulse_width_ns: float = np.NAN
pulse_width_ns: float = np.nan
gauge_length: float = np.nan
instrument_id: UTF8Str = ""
distance_units: UTF8Str = ""
Expand Down
4 changes: 2 additions & 2 deletions dascore/transform/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def _get_new_coords_and_array(patch, array, dims):
for dxs_or_val, ax in zip(dxs_or_vals, axes):
indexer = broadcast_for_index(ndims, ax, None, fill=slice(None))
if is_array(dxs_or_val):
array = np.trapz(array, x=dxs_or_val, axis=ax)[indexer]
array = np.trapezoid(array, x=dxs_or_val, axis=ax)[indexer]
else:
array = np.trapz(array, dx=dxs_or_val, axis=ax)[indexer]
array = np.trapezoid(array, dx=dxs_or_val, axis=ax)[indexer]
array, coords = _get_new_coords_and_array(patch, array, dims)
return array, coords

Expand Down
2 changes: 1 addition & 1 deletion dascore/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_registry():
# allow multiplication with offset units.
ureg.autoconvert_offset_to_baseunit = True
# set the shortest display for units.
ureg.default_format = "~"
ureg.formatter.default_format = "~"
pint.set_application_registry(ureg)
return ureg

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ keywords = ["geophysics", "distributed-acoustic-sensing"]
dependencies = [
"h5py",
"matplotlib>=3.5",
"numpy>=1.24, <2",
"numpy>=1.24",
"packaging",
"pandas>=2.0",
"pooch>=1.2",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_proc/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_wrong_kwarg_length_raises(self, random_patch):
def test_all_null_kwarg_raises(self, random_patch):
"""There must be one Non-null kwarg."""
with pytest.raises(FilterValueError, match="at least one filter"):
_ = random_patch.pass_filter(time=[None, np.NAN])
_ = random_patch.pass_filter(time=[None, np.nan])

def test_unordered_params(self, random_patch):
"""Ensure a low parameter greater than a high parameter raises."""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_transform/test_integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_simple_integration(self, ones_patch):
out = patch.integrate(dim=dim, definite=True)
assert out.shape[ax] == 1
step = to_float(patch.get_coord(dim).step)
expected_data = np.trapz(patch.data, dx=step, axis=ax)
expected_data = np.trapezoid(patch.data, dx=step, axis=ax)
ndims = len(patch.dims)
indexer = broadcast_for_index(ndims, ax, None)
assert np.allclose(out.data, expected_data[indexer])
Expand Down

0 comments on commit b372aea

Please sign in to comment.