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 11
22import numbers
3+ import warnings
34from operator import mul
45from functools import reduce
56
@@ -147,7 +148,22 @@ def total_nb_rows(self):
147148 @property
148149 def data (self ):
149150 """ 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
151167
152168 def _check_shape (self , arrseq ):
153169 """ 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):
441441 # Make sure we can add new elements to it.
442442 loaded_seq .append (SEQ_DATA ['data' ][0 ])
443443
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+
444453
445454def test_concatenate ():
446455 seq = SEQ_DATA ['seq' ].copy () # In case there is in-place modification.
You can’t perform that action at this time.
0 commit comments