Skip to content

Commit 73f6461

Browse files
committed
[Section] Add create_property method
1 parent 4edd8eb commit 73f6461

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

odml/section.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,4 +595,24 @@ def create_section(self, name, type="undefined", oid=None):
595595
"""
596596
sec = BaseSection(name=name, type=type, oid=oid)
597597
sec.parent = self
598+
598599
return sec
600+
601+
def create_property(self, name, value=None, dtype=None, oid=None):
602+
"""
603+
Create a new property that is a child of this section.
604+
605+
:param name: The name of the property.
606+
:param value: Some data value, it can be a single value or
607+
a list of homogeneous values.
608+
:param dtype: The data type of the values stored in the property,
609+
if dtype is not given, the type is deduced from the values.
610+
Check odml.DType for supported data types.
611+
:param oid: object id, UUID string as specified in RFC 4122. If no id
612+
is provided, an id will be generated and assigned.
613+
:return: The new property.
614+
"""
615+
prop = BaseProperty(name=name, value=value, dtype=dtype, oid=oid)
616+
prop.parent = self
617+
618+
return prop

0 commit comments

Comments
 (0)