Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend support for Numpy 2.0 #514

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion harmonica/_equivalent_sources/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ def fit(self, coordinates, data, weights=None):
self.region_ = vd.get_region(coordinates[:2])
coordinates = vdb.n_1d_arrays(coordinates, 3)
if self.points is None:
self.points_ = self._build_points(coordinates)
self.points_ = tuple(
p.astype(self.dtype) for p in self._build_points(coordinates)
)
else:
self.depth_ = None # set depth_ to None so we don't leave it unset
self.points_ = tuple(
Expand Down
9 changes: 6 additions & 3 deletions harmonica/_equivalent_sources/gradient_boosted.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def estimate_required_memory(self, coordinates):

Returns
-------
memory_required : float
memory_required : int
Amount of memory required to store the largest Jacobian matrix in
bytes.

Expand All @@ -157,7 +157,8 @@ def estimate_required_memory(self, coordinates):
... random_state=42,
... )
>>> eqs = EquivalentSourcesGB(window_size=2e3)
>>> eqs.estimate_required_memory(coordinates)
>>> n_bytes = eqs.estimate_required_memory(coordinates)
>>> int(n_bytes)
9800
"""
# Build the sources and assign the points_ attribute
Expand Down Expand Up @@ -216,7 +217,9 @@ def fit(self, coordinates, data, weights=None):
weights = weights.ravel()
# Build point sources
if self.points is None:
self.points_ = self._build_points(coordinates)
self.points_ = tuple(
p.astype(self.dtype) for p in self._build_points(coordinates)
)
else:
self.points_ = tuple(
p.astype(self.dtype) for p in vdb.n_1d_arrays(self.points, 3)
Expand Down
10 changes: 6 additions & 4 deletions harmonica/_forward/prism_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ def prism_layer(
coords_units: meters
properties_units: SI
>>> # Get the boundaries of the layer (will exceed the region)
>>> print(prisms.prism_layer.boundaries)
(-1.25, 11.25, 1.0, 9.0)
>>> boundaries = prisms.prism_layer.boundaries
>>> list(float(b) for b in boundaries)
[-1.25, 11.25, 1.0, 9.0]
>>> # Get the boundaries of one of the prisms
>>> print(prisms.prism_layer.get_prism((0, 2)))
(3.75, 6.25, 1.0, 3.0, 0.0, 2.0)
>>> prism = prisms.prism_layer.get_prism((0, 2))
>>> list(float(b) for b in prism)
[3.75, 6.25, 1.0, 3.0, 0.0, 2.0]
""" # noqa: W505
dims = ("northing", "easting")
# Initialize data and data_names as None
Expand Down