-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
change value related behaviors #237
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice to use now!
[1, 2, 3] | ||
>> p.value.append(4) | ||
>> print(p.value) | ||
[1, 2, 3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line should be [1, 2, 3, 4] ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe, no, I think this is correct, p.append(4)
would change it, p.value.append(4)
appends to the copy and not the property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
argh sorry, blanked out the .value.
part...
odml/property.py
Outdated
""" | ||
# Make sure boolean value 'False' gets through as well... | ||
if new_value is None or (isinstance(new_value, (list, tuple, str)) and len(new_value) == 0): | ||
self._value = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Property.dtype is currently not reset when resetting the values. Maybe this can be reset here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do have the dtype setter for this. Imho, I would rather not reset it on deleting the value(s)
In general I am happy with this implementation, there are just a few cases, where I think the behaviour should be different
prop1 = odml.Property(name='prop1', value=[3])
prop2 = odml.Property(name='prop2', value=[3.5])
prop1.merge(prop2) should result in an Error rather than Also I suggest to also add a section.extend() function similar to the property.extend() function, buts that's probably a different issue. |
strict defines wheter dtypes, respectively inferred dtypes, must match with property dtype
@JuliaSprenger you can now pass a range or anything that defines |
move stuff to main script.
The |
yes, agreed, would you mind to add it to issue #246, which was opened by Michi for the section append/extend/merge point you made |
Cool! I added a comment to the other issue. Then I think we can merge now. |
replacement pr for #236. The following changes have been made:
prop.value
returns a copy(!) of the value list. Manipulating this list will not affect the content of the property (fixes Usage of python list as odml value circumvents dtype checks #227).prop.append
,prop.extend
methods. The first only for single convertible values, the latter for lists of such as well as other properties. (fixes add append value functionality for properties is verison 1.4 #223)__setitem__
method for direct value manipulation. Property more or less behaves like a list. Passed values are checked for converability.prop.merge
method. This will sync all but the dependency and dependencyValue attributes. ValueErrors are raised, if information is set in both properties but are in conflict. (fixes Add merge functionality on value level #221)