-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass parent properties to extended dataset/attribute #321
base: dev
Are you sure you want to change the base?
Changes from all commits
ee2c16a
787d690
3b1a77f
33efc38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -376,6 +376,24 @@ def resolve_spec(self, **kwargs): | |
for attribute in inc_spec.attributes: | ||
self.__new_attributes.discard(attribute) | ||
if attribute.name in self.__attributes: | ||
# copy over the fields 'shape' and 'dims' of the parent attribute to this spec's attribute | ||
# NOTE: because the default value for the 'required' field is True, it is not possible to know whether | ||
# the 'required' field was explicitly set. thus, 'required' defaults to True no matter what the parent | ||
# specification defines. | ||
# NOTE: the value and default value of a parent attribute are also not copied to the child spec | ||
my_attribute = self.get_attribute(attribute.name) | ||
if attribute.shape is not None: | ||
if my_attribute.shape is None: | ||
my_attribute['shape'] = attribute.shape | ||
else: | ||
# TODO: test whether child shape is compatible with parent shape | ||
pass | ||
if attribute.dims is not None: | ||
if my_attribute.dims is None: | ||
my_attribute['dims'] = attribute.dims | ||
else: | ||
# TODO: test whether child dims is compatible with parent dims | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add check to make sure child is a subset of parent |
||
pass | ||
self.__overridden_attributes.add(attribute.name) | ||
continue | ||
self.set_attribute(attribute) | ||
|
@@ -695,6 +713,30 @@ def __is_sub_dtype(cls, orig, new): | |
@docval({'name': 'inc_spec', 'type': 'DatasetSpec', 'doc': 'the data type this specification represents'}) | ||
def resolve_spec(self, **kwargs): | ||
inc_spec = getargs('inc_spec', kwargs) | ||
# copy over fields of the parent dataset to this spec | ||
# NOTE: because the default value for the 'quantity' field is 1, it is not possible to know whether | ||
# the 'quantity' field was explicitly set. thus, 'quantity' defaults to 1 no matter what the parent | ||
# specification defines. | ||
# NOTE: the default value of a parent attribute is also not copied to the child spec | ||
if inc_spec.dtype is not None: | ||
if self.dtype is None: | ||
self['dtype'] = inc_spec.dtype | ||
else: | ||
# TODO: test whether child dtype is compatible with parent dtype | ||
ajtritt marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add check to make sure child is a subset of parent |
||
# e.g., if parent dtype is int, child dtype cannot be text | ||
pass | ||
if inc_spec.shape is not None: | ||
if self.shape is None: | ||
self['shape'] = inc_spec.shape | ||
elif inc_spec.shape is not None: | ||
# TODO: test whether child shape is compatible with parent shape | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add check to make sure child is a subset of parent |
||
pass | ||
if inc_spec.dims is not None: | ||
if self.dims is None: | ||
self['dims'] = inc_spec.dims | ||
elif inc_spec.dims is not None: | ||
# TODO: test whether child dims is compatible with parent dims | ||
pass | ||
if isinstance(self.dtype, list): | ||
# merge the new types | ||
inc_dtype = inc_spec.dtype | ||
|
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.
add check to make sure child is a subset of parent