Skip to content

Commit

Permalink
Update examples in docstrings to support Numpy 2
Browse files Browse the repository at this point in the history
Convert Numpy scalars to Python numbers so the outputs of examples that
are being compared when running doctests support Numpy>=2.0.
  • Loading branch information
santisoler committed Jun 18, 2024
1 parent 41c4004 commit 2083afe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 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
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

0 comments on commit 2083afe

Please sign in to comment.