diff --git a/CHANGES.rst b/CHANGES.rst index d8d4586f..71215467 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,12 @@ +4.2.1 (unreleased) +================== + +Bug fixes +--------- + +- Avoid numpy>=2.0 deprecation warnings being raised in the ``__array__()`` + methods of ``Payload`` and ``Frame.__array__()``. [#525] + 4.2 (2024-07-17) ================ diff --git a/baseband/base/frame.py b/baseband/base/frame.py index 9caaaa9e..1db5e6d5 100644 --- a/baseband/base/frame.py +++ b/baseband/base/frame.py @@ -179,12 +179,12 @@ def fill_value(self): def fill_value(self, fill_value): self._fill_value = fill_value - def __array__(self, dtype=None): + def __array__(self, dtype=None, copy=None): """Interface to arrays.""" - if dtype is None or dtype == self.dtype: + if not copy and (dtype is None or dtype == self.dtype): return self.data else: - return self.data.astype(dtype) + return self.data.astype(dtype, copy=True) # Header behaves as a dictionary, while Payload can be indexed/sliced. # Let frame behave appropriately. diff --git a/baseband/base/payload.py b/baseband/base/payload.py index 271894dd..8556a039 100644 --- a/baseband/base/payload.py +++ b/baseband/base/payload.py @@ -181,12 +181,12 @@ def fromdata(cls, data, header=None, bps=2): return cls(words, sample_shape=sample_shape, bps=bps, complex_data=complex_data) - def __array__(self, dtype=None): + def __array__(self, dtype=None, copy=None): """Interface to arrays.""" - if dtype is None or dtype == self.dtype: + if not copy and (dtype is None or dtype == self.dtype): return self.data else: - return self.data.astype(dtype) + return self.data.astype(dtype, copy=True) @property def nbytes(self):