File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
1
2
2
import numbers
3
+ import warnings
3
4
from operator import mul
4
5
from functools import reduce
5
6
@@ -147,7 +148,22 @@ def total_nb_rows(self):
147
148
@property
148
149
def data (self ):
149
150
""" Elements in this array sequence. """
150
- return self ._data
151
+ warnings .warn ("The 'ArraySequence.data' property has been deprecated"
152
+ " in favor of 'ArraySequence.get_data()'." ,
153
+ DeprecationWarning ,
154
+ stacklevel = 2 )
155
+ return self .get_data ()
156
+
157
+ def get_data (self ):
158
+ """ Returns a copy of the elements in this array sequence.
159
+
160
+ Notes
161
+ -----
162
+ To modify the data on this array sequence, one can use
163
+ in-place mathematical operators (e.g., `seq += ...`) or the use
164
+ assignment operator (i.e, `seq[...] = value`).
165
+ """
166
+ return self .copy ()._data
151
167
152
168
def _check_shape (self , arrseq ):
153
169
""" Check whether this array sequence is compatible with another. """
Original file line number Diff line number Diff line change @@ -441,6 +441,15 @@ def test_save_and_load_arraysequence(self):
441
441
# Make sure we can add new elements to it.
442
442
loaded_seq .append (SEQ_DATA ['data' ][0 ])
443
443
444
+ def test_get_data (self ):
445
+ seq_view = SEQ_DATA ['seq' ][::2 ]
446
+ check_arr_seq_view (seq_view , SEQ_DATA ['seq' ])
447
+
448
+ # We make sure the array sequence data does not
449
+ # contain more elements than it is supposed to.
450
+ data = seq_view .get_data ()
451
+ assert len (data ) < len (seq_view ._data )
452
+
444
453
445
454
def test_concatenate ():
446
455
seq = SEQ_DATA ['seq' ].copy () # In case there is in-place modification.
You can’t perform that action at this time.
0 commit comments