-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix DynamicTable slicing and add SimpleMultiContainer (#449)
* Fix case where non-AbstractContainer is base class * Update container.py * only use astype if not already requestd type * fix slicing bugs in DynamicTable * add SimpleMultiContainer * add method to check if data_type is a subtype of another * update inits * fix slicing and test roundtrip * update schema submodule * update changelog * remove unnecessary method * fix documentation * add more tests for DynamicTableRegion indexing * remove f-string * construct literal DataFrames with consistent order * simplify conditional * add tuple * ignore dtype when checking dataframes * remove tuple * remove check on type of data in column * remove ElementIdentifiers data object type check * convert to list for h5py 2.9 compatability * use assertRaisesWith * simplify SimpleMultiContainer tests * Update tests/unit/common/test_multi.py Co-authored-by: Ryan Ly <rly@lbl.gov> * pin schema revision * update schema submodule * Update CHANGELOG.md Co-authored-by: Ryan Ly <rly@lbl.gov> Co-authored-by: Ryan Ly <rly@lbl.gov>
- Loading branch information
Showing
13 changed files
with
307 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule hdmf-common-schema
updated
10 files
+7 −8 | .github/PULL_REQUEST_TEMPLATE/release.md | |
+1 −0 | README.md | |
+13 −0 | common/base.yaml | |
+2 −1 | common/namespace.yaml | |
+2 −0 | common/sparse.yaml | |
+1 −0 | common/table.yaml | |
+1 −1 | docs/source/conf.py | |
+1 −1 | docs/source/conf_doc_autogen.py | |
+8 −0 | docs/source/format_release_notes.rst | |
+7 −8 | docs/source/software_process.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import table # noqa: F401 | ||
from . import multi # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from ...build import ObjectMapper | ||
from ..multi import SimpleMultiContainer | ||
from .. import register_map | ||
from ...container import Container, Data | ||
|
||
|
||
@register_map(SimpleMultiContainer) | ||
class SimpleMultiContainerMap(ObjectMapper): | ||
|
||
@ObjectMapper.object_attr('containers') | ||
def containers_attr(self, container, manager): | ||
return [c for c in container.containers.values() if isinstance(c, Container)] | ||
|
||
@ObjectMapper.constructor_arg('containers') | ||
def containers_carg(self, builder, manager): | ||
return [manager.construct(sub) for sub in builder.datasets.values() if manager.is_sub_data_type(sub, 'Data')] +\ | ||
[manager.construct(sub) for sub in builder.groups.values() if manager.is_sub_data_type(sub, 'Container')] | ||
|
||
@ObjectMapper.object_attr('datas') | ||
def datas_attr(self, container, manager): | ||
return [c for c in container.containers.values() if isinstance(c, Data)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from ..container import Container, Data, MultiContainerInterface | ||
from ..utils import docval, call_docval_func, popargs | ||
|
||
from . import register_class | ||
|
||
|
||
@register_class('SimpleMultiContainer') | ||
class SimpleMultiContainer(MultiContainerInterface): | ||
|
||
__clsconf__ = { | ||
'attr': 'containers', | ||
'type': (Container, Data), | ||
'add': 'add_container', | ||
'get': 'get_container', | ||
} | ||
|
||
@docval({'name': 'name', 'type': str, 'doc': 'the name of this container'}, | ||
{'name': 'containers', 'type': (list, tuple), 'default': None, | ||
'doc': 'the Container or Data objects in this file'}) | ||
def __init__(self, **kwargs): | ||
containers = popargs('containers', kwargs) | ||
call_docval_func(super().__init__, kwargs) | ||
self.containers = containers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from hdmf.container import Container, Data | ||
from hdmf.common import SimpleMultiContainer | ||
from hdmf.testing import TestCase, H5RoundTripMixin | ||
|
||
|
||
class SimpleMultiContainerRoundTrip(H5RoundTripMixin, TestCase): | ||
|
||
def setUpContainer(self): | ||
containers = [ | ||
Container('container1'), | ||
Container('container2'), | ||
Data('data1', [0, 1, 2, 3, 4]), | ||
Data('data2', [0.0, 1.0, 2.0, 3.0, 4.0]), | ||
] | ||
multi_container = SimpleMultiContainer('multi', containers) | ||
return multi_container |
Oops, something went wrong.