Skip to content

Commit

Permalink
Using np.asarray() to support numpy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ndilalla committed Aug 13, 2024
1 parent 4d01903 commit 0a28bb0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions astromodels/functions/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ def __call__(self, x):

# Transform the input to an array of floats. If x is a single number, this will be an array of size 1

new_input = np.array(x, dtype=float, ndmin=1, copy=False)
new_input = np.asarray(x, dtype=float)

# Compute the function

Expand Down Expand Up @@ -1705,8 +1705,8 @@ def __call__(self, x, y, *args, **kwargs):

# Transform the input to an array of floats

new_x = np.array(x, dtype=float, ndmin=1, copy=False)
new_y = np.array(y, dtype=float, ndmin=1, copy=False)
new_x = np.asarray(x, dtype=float)
new_y = np.asarray(y, dtype=float)

# Compute the function

Expand Down Expand Up @@ -1876,9 +1876,9 @@ def __call__(self, x, y, z):
# This is either a single number or a list
# Transform the input to an array of floats

new_x = np.array(x, dtype=float, ndmin=1, copy=False)
new_y = np.array(y, dtype=float, ndmin=1, copy=False)
new_z = np.array(z, dtype=float, ndmin=1, copy=False)
new_x = np.asarray(x, dtype=float)
new_y = np.asarray(y, dtype=float)
new_z = np.asarray(z, dtype=float)

# Compute the function

Expand Down
2 changes: 1 addition & 1 deletion astromodels/functions/functions_1D/extinction.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def evaluate(self, x, e_bmv, rv, redshift):

if isinstance(x, astropy_units.Quantity):

_x = np.array(x.to("keV").value, ndmin=1, copy=False, dtype=float)
_x = np.asarray(x.to("keV").value, dtype=float)

_unit = astropy_units.cm**2
_y_unit = astropy_units.dimensionless_unscaled
Expand Down
4 changes: 2 additions & 2 deletions astromodels/functions/template_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ def _interpolate(self, energies, scale, parameters_values):
# a dimensionless quantity (actually we take the .value property) because otherwise
# the logarithm below will fail.

energies = np.array(
energies.to("keV").value, ndmin=1, copy=False, dtype=float
energies = np.asarray(
energies.to("keV").value, dtype=float
)

# Same for the scale
Expand Down
2 changes: 1 addition & 1 deletion astromodels/xspec/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def evaluate(self, x, $PARAMETERS_NAMES$):
if isinstance(x, u.Quantity):
x = np.array(x.to('keV').value, ndmin=1, copy=False, dtype=float)
x = np.asarray(x.to('keV').value, dtype=float)
quantity = True
Expand Down

0 comments on commit 0a28bb0

Please sign in to comment.