File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,17 @@ class PulseSequence:
237
237
Due to the heavy use of NumPy's :func:`~numpy.einsum` function,
238
238
results have a floating point error of ~1e-13.
239
239
"""
240
+ __array_interface__ = {
241
+ 'shape' : (),
242
+ 'typestr' : '|O' ,
243
+ 'version' : 3
244
+ }
245
+ """Describes to NumPy how to convert this object into an array.
246
+
247
+ Since :class:`PulseSequence` is iterable (through
248
+ :meth:`__getitem__`), NumPy would otherwise try to create an
249
+ ndarray of single-segment :class:`PulseSequence` s.
250
+ """
240
251
241
252
def __init__ (self , * args , ** kwargs ) -> None :
242
253
"""Initialize a PulseSequence instance."""
Original file line number Diff line number Diff line change @@ -100,6 +100,14 @@ def test_slicing(self):
100
100
with self .assertRaises (IndexError ):
101
101
pulse ['a' ]
102
102
103
+ def test_array (self ):
104
+ """Test array of PulseSequences."""
105
+ pulses = list (testutil .rand_pulse_sequence (2 , 24 )[::3 ])
106
+ array = np .array (pulses )
107
+
108
+ self .assertIs (array .dtype , np .dtype ('O' ))
109
+ self .assertEqual (array .shape , (8 ,))
110
+
103
111
def test_concatenate_without_filter_function (self ):
104
112
"""Concatenate two Spin Echos without filter functions."""
105
113
tau = 10
You can’t perform that action at this time.
0 commit comments