Skip to content

Commit

Permalink
Update spec.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rly authored Jul 6, 2024
1 parent 62edbe4 commit 5736837
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/hdmf/spec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ def build_const_args(cls, spec_dict):
{'name': 'linkable', 'type': bool, 'doc': 'whether or not this group can be linked', 'default': True},
{'name': 'quantity', 'type': (str, int), 'doc': 'the required number of allowed instance', 'default': 1},
{'name': 'default_value', 'type': None, 'doc': 'a default value for this dataset', 'default': None},
{'name': 'value', 'type': None, 'doc': 'a fixed value for this dataset', 'default': None},
{'name': 'data_type_def', 'type': str, 'doc': 'the data type this specification represents', 'default': None},
{'name': 'data_type_inc', 'type': (str, 'DatasetSpec'),
'doc': 'the data type this specification extends', 'default': None},
Expand All @@ -662,7 +663,8 @@ class DatasetSpec(BaseStorageSpec):

@docval(*_dataset_args)
def __init__(self, **kwargs):
doc, shape, dims, dtype, default_value = popargs('doc', 'shape', 'dims', 'dtype', 'default_value', kwargs)
doc, shape, dims, dtype = popargs('doc', 'shape', 'dims', 'dtype', kwargs)
default_value, value = popargs('default_value', 'value', kwargs)
if shape is not None:
self['shape'] = shape
if dims is not None:
Expand All @@ -685,6 +687,8 @@ def __init__(self, **kwargs):
super().__init__(doc, **kwargs)
if default_value is not None:
self['default_value'] = default_value
if value is not None:
self['value'] = value

Check warning on line 691 in src/hdmf/spec/spec.py

View check run for this annotation

Codecov / codecov/patch

src/hdmf/spec/spec.py#L691

Added line #L691 was not covered by tests
if self.name is not None:
valid_quant_vals = [1, 'zero_or_one', ZERO_OR_ONE]
if self.quantity not in valid_quant_vals:
Expand Down Expand Up @@ -762,6 +766,11 @@ def default_value(self):
'''The default value of the dataset or None if not specified'''
return self.get('default_value', None)

@property
def value(self):
'''The fixed value of the dataset or None if not specified'''
return self.get('value', None)

@classmethod
def dtype_spec_cls(cls):
''' The class to use when constructing DtypeSpec objects
Expand Down

0 comments on commit 5736837

Please sign in to comment.