[med-svn] [Git][med-team/hdmf][upstream] New upstream version 3.3.2

Andreas Tille (@tille) gitlab at salsa.debian.org
Tue Jul 19 13:49:31 BST 2022



Andreas Tille pushed to branch upstream at Debian Med / hdmf


Commits:
36625ded by Andreas Tille at 2022-07-19T14:45:21+02:00
New upstream version 3.3.2
- - - - -


7 changed files:

- PKG-INFO
- src/hdmf.egg-info/PKG-INFO
- src/hdmf/_version.py
- src/hdmf/build/classgenerator.py
- src/hdmf/data_utils.py
- tests/unit/build_tests/test_classgenerator.py
- tests/unit/utils_test/test_core_GenericDataChunkIterator.py


Changes:

=====================================
PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: hdmf
-Version: 3.3.1
+Version: 3.3.2
 Summary: A package for standardizing hierarchical object data
 Home-page: https://github.com/hdmf-dev/hdmf
 Author: Andrew Tritt


=====================================
src/hdmf.egg-info/PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: hdmf
-Version: 3.3.1
+Version: 3.3.2
 Summary: A package for standardizing hierarchical object data
 Home-page: https://github.com/hdmf-dev/hdmf
 Author: Andrew Tritt


=====================================
src/hdmf/_version.py
=====================================
@@ -8,11 +8,11 @@ import json
 
 version_json = '''
 {
- "date": "2022-05-25T08:28:39-0700",
+ "date": "2022-06-27T16:04:19-0700",
  "dirty": false,
  "error": null,
- "full-revisionid": "2ae871f26b5ebb0536ac638b073a3233ac8ed5b3",
- "version": "3.3.1"
+ "full-revisionid": "0e50852145bbf9a4676b6edc936317f882f9a47e",
+ "version": "3.3.2"
 }
 '''  # END VERSION_JSON
 


=====================================
src/hdmf/build/classgenerator.py
=====================================
@@ -304,6 +304,7 @@ class CustomClassGenerator:
             for f in new_args:
                 new_kwargs[f] = popargs(f, kwargs) if f in kwargs else None
             base.__init__(self, **kwargs)  # special case: need to pass self to __init__
+            # TODO should super() be used above instead of base?
             for f, arg_val in new_kwargs.items():
                 setattr(self, f, arg_val)
         classdict['__init__'] = __init__
@@ -361,4 +362,45 @@ class MCIClassGenerator(CustomClassGenerator):
                 if issubclass(b, MultiContainerInterface):
                     break
             else:
-                bases.insert(0, MultiContainerInterface)
+                if issubclass(MultiContainerInterface, bases[0]):
+                    # if bases[0] is Container or another superclass of MCI, then make sure MCI goes first
+                    # otherwise, MRO is ambiguous
+                    bases.insert(0, MultiContainerInterface)
+                else:
+                    # bases[0] is not a subclass of MCI and not a superclass of MCI. place that class first
+                    # before MCI. that class __init__ should call super().__init__ which will call the
+                    # MCI init
+                    bases.insert(1, MultiContainerInterface)
+
+    @classmethod
+    def set_init(cls, classdict, bases, docval_args, not_inherited_fields, name):
+        if '__clsconf__' in classdict:
+            previous_init = classdict['__init__']
+
+            @docval(*docval_args, allow_positional=AllowPositional.WARNING)
+            def __init__(self, **kwargs):
+                # first call the next superclass init
+                # previous_init(**kwargs)
+
+                # store the values passed to init for each MCI attribute
+                new_kwargs = list()
+                for field_clsconf in classdict['__clsconf__']:
+                    attr_name = field_clsconf['attr']
+                    add_method_name = field_clsconf['add']
+                    new_kwarg = dict(
+                        attr_name=attr_name,
+                        value=popargs(attr_name, kwargs) if attr_name in kwargs else None,
+                        add_method_name=add_method_name
+                    )
+                    new_kwargs.append(new_kwarg)
+
+                # call the parent class init without the MCI attribute
+                previous_init(self, **kwargs)
+
+                # call the add method for each MCI attribute
+                for new_kwarg in new_kwargs:
+                    add_method = getattr(self, new_kwarg['add_method_name'])
+                    add_method(new_kwarg['value'])
+
+            # override __init__
+            classdict['__init__'] = __init__


=====================================
src/hdmf/data_utils.py
=====================================
@@ -221,12 +221,15 @@ class GenericDataChunkIterator(AbstractDataChunkIterator):
         array_buffer_shape = np.array(self.buffer_shape)
         array_maxshape = np.array(self.maxshape)
         assert all(array_buffer_shape > 0), f"Some dimensions of buffer_shape ({self.buffer_shape}) are less than zero!"
+        assert all(
+            array_chunk_shape <= array_maxshape
+        ), f"Some dimensions of chunk_shape ({self.chunk_shape}) exceed the data dimensions ({self.maxshape})!"
         assert all(
             array_buffer_shape <= array_maxshape
         ), f"Some dimensions of buffer_shape ({self.buffer_shape}) exceed the data dimensions ({self.maxshape})!"
         assert all(
             array_chunk_shape <= array_buffer_shape
-        ), f"Some dimensions of chunk_shape ({self.chunk_shape}) exceed the manual buffer shape ({self.buffer_shape})!"
+        ), f"Some dimensions of chunk_shape ({self.chunk_shape}) exceed the buffer shape ({self.buffer_shape})!"
         assert all((array_buffer_shape % array_chunk_shape == 0)[array_buffer_shape != array_maxshape]), (
             f"Some dimensions of chunk_shape ({self.chunk_shape}) do not "
             f"evenly divide the buffer shape ({self.buffer_shape})!"


=====================================
tests/unit/build_tests/test_classgenerator.py
=====================================
@@ -296,6 +296,48 @@ class TestDynamicContainer(TestCase):
         assert multi.bars['my_bar'] == Bar(name='my_bar', data=list(range(10)), attr1='value1', attr2=10)
         assert multi.attr3 == 5.
 
+    def test_multi_container_spec_with_inc(self):
+        multi_spec = GroupSpec(
+            doc='A test extension that contains a multi',
+            data_type_def='Multi',
+            data_type_inc=self.bar_spec,
+            groups=[
+                GroupSpec(data_type_inc=self.bar_spec, doc='test multi', quantity='*')
+            ],
+            attributes=[
+                AttributeSpec(name='attr3', doc='a float attribute', dtype='float')
+            ]
+        )
+        self.spec_catalog.register_spec(multi_spec, 'extension.yaml')
+        Bar = self.type_map.get_dt_container_cls('Bar', CORE_NAMESPACE)
+        Multi = self.type_map.get_dt_container_cls('Multi', CORE_NAMESPACE)
+        assert issubclass(Multi, MultiContainerInterface)
+        assert issubclass(Multi, Bar)
+        assert Multi.__mro__ == (Multi, Bar, MultiContainerInterface, Container, AbstractContainer, object)
+        assert Multi.__clsconf__ == [
+            dict(
+                attr='bars',
+                type=Bar,
+                add='add_bars',
+                get='get_bars',
+                create='create_bars'
+            )
+        ]
+
+        multi = Multi(
+            name='my_multi',
+            bars=[Bar(name='my_bar', data=list(range(10)), attr1='value1', attr2=10)],
+            data=list(range(10)),  # from data_type_inc: Bar
+            attr1='value1',  # from data_type_inc: Bar
+            attr2=10,  # from data_type_inc: Bar
+            attr3=5.
+        )
+        assert multi.data == list(range(10))
+        assert multi.attr1 == 'value1'
+        assert multi.attr2 == 10
+        assert multi.bars['my_bar'] == Bar(name='my_bar', data=list(range(10)), attr1='value1', attr2=10)
+        assert multi.attr3 == 5.
+
 
 class TestGetClassSeparateNamespace(TestCase):
 
@@ -887,7 +929,7 @@ class TestMCIProcessFieldSpec(TestCase):
         MCIClassGenerator.process_field_spec(
             classdict=classdict,
             docval_args=docval_args,
-            parent_cls=Container,
+            parent_cls=Bar,
             attr_name='empty_bars',
             not_inherited_fields=not_inherited_fields,
             type_map=self.type_map,
@@ -916,10 +958,10 @@ class TestMCIProcessFieldSpec(TestCase):
                 )
             ]
         )
-        bases = [Container]
+        bases = [Bar]
         docval_args = []
         MCIClassGenerator.post_process(classdict, bases, docval_args, multi_spec)
-        self.assertEqual(bases, [MultiContainerInterface, Container])
+        self.assertEqual(bases, [Bar, MultiContainerInterface])
 
     def test_post_process_already_multi(self):
         class Multi1(MultiContainerInterface):
@@ -948,3 +990,30 @@ class TestMCIProcessFieldSpec(TestCase):
         docval_args = []
         MCIClassGenerator.post_process(classdict, bases, docval_args, multi_spec)
         self.assertEqual(bases, [Multi1])
+
+    def test_post_process_container(self):
+        class Multi1(MultiContainerInterface):
+            pass
+
+        multi_spec = GroupSpec(
+            doc='A test extension that contains a multi and extends a multi',
+            data_type_def='Multi1',
+            groups=[
+                GroupSpec(data_type_inc='EmptyBar', doc='test multi', quantity='*')
+            ],
+        )
+        classdict = dict(
+            __clsconf__=[
+                dict(
+                    attr='empty_bars',
+                    type=EmptyBar,
+                    add='add_empty_bars',
+                    get='get_empty_bars',
+                    create='create_empty_bars'
+                )
+            ]
+        )
+        bases = [Container]
+        docval_args = []
+        MCIClassGenerator.post_process(classdict, bases, docval_args, multi_spec)
+        self.assertEqual(bases, [MultiContainerInterface, Container])


=====================================
tests/unit/utils_test/test_core_GenericDataChunkIterator.py
=====================================
@@ -84,12 +84,24 @@ class GenericDataChunkIteratorTests(TestCase):
         ):
             self.TestNumpyArrayDataChunkIterator(array=self.test_array, chunk_shape=(1580, 316), chunk_mb=1)
 
+        chunk_shape = (2001, 384)
+        with self.assertRaisesWith(
+            exc_type=AssertionError,
+            exc_msg=(
+                f"Some dimensions of chunk_shape ({chunk_shape}) exceed the "
+                f"data dimensions ((2000, 384))!"
+            ),
+        ):
+            self.TestNumpyArrayDataChunkIterator(
+                array=self.test_array, chunk_shape=chunk_shape
+            )
+
         buffer_shape = (1000, 192)
         chunk_shape = (100, 384)
         with self.assertRaisesWith(
             exc_type=AssertionError,
             exc_msg=(
-                f"Some dimensions of chunk_shape ({chunk_shape}) exceed the manual "
+                f"Some dimensions of chunk_shape ({chunk_shape}) exceed the "
                 f"buffer shape ({buffer_shape})!"
             ),
         ):



View it on GitLab: https://salsa.debian.org/med-team/hdmf/-/commit/36625deda208b0b59344a9a2315f96a88a0dddb6

-- 
View it on GitLab: https://salsa.debian.org/med-team/hdmf/-/commit/36625deda208b0b59344a9a2315f96a88a0dddb6
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20220719/d3a0cc9e/attachment-0001.htm>


More information about the debian-med-commit mailing list