From e9762b7592db044c382eb5399b11ac2f774a6bb2 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:32:32 -0400 Subject: [PATCH] MNT: Compat with numpy 2 and astropy 6.1 --- CHANGES.rst | 2 ++ specutils/utils/quantity_model.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 0c8248dcb..d7d3344fe 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,8 @@ Bug Fixes Other Changes and Additions ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- Compatibility with numpy 2.0 and astropy 6.1. [#1130] + 1.13.0 (2024-02-19) ------------------- diff --git a/specutils/utils/quantity_model.py b/specutils/utils/quantity_model.py index 07ec57064..a25d661dd 100644 --- a/specutils/utils/quantity_model.py +++ b/specutils/utils/quantity_model.py @@ -1,6 +1,8 @@ +import numpy as np from astropy import units as u __all__ = ['QuantityModel'] +_NUMPY_COPY_IF_NEEDED = False if np.__version__.startswith("1.") else None class QuantityModel: @@ -72,4 +74,4 @@ def __repr__(self): def __call__(self, x, *args, **kwargs): unitlessx = x.to(self.input_units).value result = self.unitless_model(unitlessx, *args, **kwargs) - return u.Quantity(result, self.return_units, copy=False) + return u.Quantity(result, self.return_units, copy=_NUMPY_COPY_IF_NEEDED)