Skip to content

Commit 44a403f

Browse files
committed
[property.py] Add List/Tuple-Format Tuple Validation for Append and Extend
1 parent 8064e60 commit 44a403f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

odml/property.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,11 @@ def extend(self, obj, strict=True):
794794
return
795795

796796
new_value = self._convert_value_input(obj)
797+
798+
if self._dtype.endswith("-tuple"):
799+
t_count = int(self._dtype.split("-")[0])
800+
new_value = odml_tuple_import(t_count, new_value)
801+
797802
if len(new_value) > 0 and strict and \
798803
dtypes.infer_dtype(new_value[0]) != self.dtype:
799804

@@ -831,6 +836,10 @@ def append(self, obj, strict=True):
831836
if len(new_value) > 1:
832837
raise ValueError("odml.property.append: Use extend to add a list of values!")
833838

839+
if self._dtype.endswith("-tuple"):
840+
t_count = int(self._dtype.split("-")[0])
841+
new_value = odml_tuple_import(t_count, new_value)
842+
834843
if len(new_value) > 0 and strict and \
835844
dtypes.infer_dtype(new_value[0]) != self.dtype:
836845

0 commit comments

Comments
 (0)