Skip to content

Commit ac7e0f7

Browse files
committed
[Property] Provide 'values' and 'value' on init
1 parent 8fb4422 commit ac7e0f7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

odml/property.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class BaseProperty(base.BaseObject):
1313
"""An odML Property"""
1414
_format = frmt.Property
1515

16-
def __init__(self, name=None, value=None, parent=None, unit=None,
16+
def __init__(self, name=None, values=None, parent=None, unit=None,
1717
uncertainty=None, reference=None, definition=None,
1818
dependency=None, dependency_value=None, dtype=None,
19-
value_origin=None, oid=None):
19+
value_origin=None, oid=None, value=None):
2020
"""
2121
Create a new Property. If a value without an explicitly stated dtype
2222
has been provided, the method will try to infer the value's dtype.
@@ -31,8 +31,8 @@ def __init__(self, name=None, value=None, parent=None, unit=None,
3131
>>> p.dtype
3232
>>> int
3333
:param name: The name of the property.
34-
:param value: Some data value, it can be a single value or
35-
a list of homogeneous values.
34+
:param values: Some data value, it can be a single value or
35+
a list of homogeneous values.
3636
:param unit: The unit of the stored data.
3737
:param uncertainty: The uncertainty (e.g. the standard deviation)
3838
associated with a measure value.
@@ -48,6 +48,8 @@ def __init__(self, name=None, value=None, parent=None, unit=None,
4848
:param oid: object id, UUID string as specified in RFC 4122. If no id is provided,
4949
an id will be generated and assigned. An id has to be unique
5050
within an odML Document.
51+
:param value: Legacy code to the 'values' attribute. If 'values' is provided,
52+
any data provided via 'value' will be ignored.
5153
"""
5254
try:
5355
if oid is not None:
@@ -79,7 +81,9 @@ def __init__(self, name=None, value=None, parent=None, unit=None,
7981
print("Warning: Unknown dtype '%s'." % dtype)
8082

8183
self._values = []
82-
self.values = value
84+
self.values = values
85+
if not values and (value or isinstance(value, bool)):
86+
self.values = value
8387

8488
self.parent = parent
8589

0 commit comments

Comments
 (0)