From f6d32fe230e54ce34dec1b9e91ac87ecd362a0d4 Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter Date: Wed, 2 Oct 2024 22:47:06 +0200 Subject: [PATCH] Add __array_interface__ --- filter_functions/pulse_sequence.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/filter_functions/pulse_sequence.py b/filter_functions/pulse_sequence.py index 011df38..decf757 100644 --- a/filter_functions/pulse_sequence.py +++ b/filter_functions/pulse_sequence.py @@ -237,6 +237,17 @@ class PulseSequence: Due to the heavy use of NumPy's :func:`~numpy.einsum` function, results have a floating point error of ~1e-13. """ + __array_interface__ = { + 'shape': (), + 'typestr': '|O', + 'version': 3 + } + """Describes to NumPy how to convert this object into an array. + + Since :class:`PulseSequence` is iterable (through + :meth:`__getitem__`), NumPy would otherwise try to create an + ndarray of single-segment :class:`PulseSequence` s. + """ def __init__(self, *args, **kwargs) -> None: """Initialize a PulseSequence instance."""