@@ -209,35 +209,20 @@ def _validate_parent(new_parent):
209209 @property
210210 def value (self ):
211211 """
212- Returns the value(s) stored in this property. Method always returns a list
213- that is a copy (!) of the stored value. Changing this list will NOT change
214- the property.
215- For manipulation of the stored values use the append, extend, and direct
216- access methods (using brackets).
217-
218- For example:
219- >>> p = odml.Property("prop", value=[1, 2, 3])
220- >>> print(p.value)
221- [1, 2, 3]
222- >>> p.value.append(4)
223- >>> print(p.value)
224- [1, 2, 3]
212+ Deprecated alias of 'values'. Will be removed with the next minor release.
213+ """
214+ print ("The attribute 'value' is deprecated. Please use 'values' instead." )
215+ return self .values
225216
226- Individual values can be accessed and manipulated like this:
227- >>> print(p[0])
228- [1]
229- >>> p[0] = 4
230- >>> print(p[0])
231- [4]
217+ @value .setter
218+ def value (self , new_value ):
219+ """
220+ Deprecated alias of 'values'. Will be removed with the next minor release.
232221
233- The values can be iterated e.g. with a loop:
234- >>> for v in p.value:
235- >>> print(v)
236- 4
237- 2
238- 3
222+ :param new_value: a single value or list of values.
239223 """
240- return list (self ._values )
224+ print ("The attribute 'value' is deprecated. Please use 'values' instead." )
225+ self .values = new_value
241226
242227 def value_str (self , index = 0 ):
243228 """
@@ -285,31 +270,6 @@ def _convert_value_input(self, new_value):
285270 "unsupported data type for values: %s" % type (new_value ))
286271 return new_value
287272
288- @value .setter
289- def value (self , new_value ):
290- """
291- Set the value of the property discarding any previous information.
292- Method will try to convert the passed value to the dtype of
293- the property and raise an ValueError if not possible.
294-
295- :param new_value: a single value or list of values.
296- """
297- # Make sure boolean value 'False' gets through as well...
298- if new_value is None or \
299- (isinstance (new_value , (list , tuple , str )) and len (new_value ) == 0 ):
300- self ._values = []
301- return
302-
303- new_value = self ._convert_value_input (new_value )
304-
305- if self ._dtype is None :
306- self ._dtype = dtypes .infer_dtype (new_value [0 ])
307-
308- if not self ._validate_values (new_value ):
309- raise ValueError ("odml.Property.value: passed values are not of "
310- "consistent type!" )
311- self ._values = [dtypes .get (v , self .dtype ) for v in new_value ]
312-
313273 @property
314274 def values (self ):
315275 """
@@ -364,7 +324,7 @@ def values(self, new_value):
364324 self ._dtype = dtypes .infer_dtype (new_value [0 ])
365325
366326 if not self ._validate_values (new_value ):
367- raise ValueError ("odml.Property.value : passed values are not of "
327+ raise ValueError ("odml.Property.values : passed values are not of "
368328 "consistent type!" )
369329 self ._values = [dtypes .get (v , self .dtype ) for v in new_value ]
370330
0 commit comments