Repository: hdmf-dev/hdmf

Issue:
Add shape attribute on base classes of DynamicTableRegion
In https://github.com/hdmf-dev/hdmf/pull/191 we added the ``shape`` property to ``DynamicTableRegion`` For consistency we should add the ``shape`` property to the parent classes as well. This should require only adding  ``shape`` to ``container.Data``.  This should also make shape validation on these objects more efficient. 

## Checklist

- [X] Have you ensured the feature or change was not already [reported](https://github.com/hdmf-dev/hdmf/issues) ?
- [X] Have you included a brief and descriptive title?
- [X] Have you included a clear description of the problem you are trying to solve?
- [X] Have you included a minimal code snippet that reproduces the issue you are encountering?
- [X] Have you checked our [Contributing](https://github.com/hdmf-dev/hdmf/blob/dev/docs/CONTRIBUTING.rst) document?


Discussion:

Patch:
diff --git a/src/hdmf/container.py b/src/hdmf/container.py
index 2831aa8..2932f1e 100644
--- a/src/hdmf/container.py
+++ b/src/hdmf/container.py
@@ -3,7 +3,7 @@ from abc import abstractmethod
 from uuid import uuid4
 from six import with_metaclass
 from .utils import docval, get_docval, call_docval_func, getargs, ExtenderMeta
-from .data_utils import DataIO
+from .data_utils import DataIO, get_shape
 from warnings import warn
 import h5py
 
@@ -390,6 +390,15 @@ class Data(AbstractContainer):
     def data(self):
         return self.__data
 
+    @property
+    def shape(self):
+        """
+        Get the shape of the data represented by this container
+        :return: Shape tuple
+        :rtype: tuple of ints
+        """
+        return get_shape(self.__data)
+
     @docval({'name': 'dataio', 'type': DataIO, 'doc': 'the DataIO to apply to the data held by this Data'})
     def set_dataio(self, **kwargs):
         """


Test patch:
diff --git a/tests/unit/test_container.py b/tests/unit/test_container.py
index 2d16dea..842517e 100644
--- a/tests/unit/test_container.py
+++ b/tests/unit/test_container.py
@@ -1,6 +1,7 @@
 import unittest
 
 from hdmf.container import AbstractContainer, Container, Data
+import numpy as np
 
 
 class Subcontainer(Container):
@@ -133,6 +134,20 @@ class TestData(unittest.TestCase):
         data_obj = Data('my_data', [])
         self.assertFalse(data_obj)
 
+    def test_shape_nparray(self):
+        """
+        Test that shape works for np.array
+        """
+        data_obj = Data('my_data', np.arange(10).reshape(2, 5))
+        self.assertTupleEqual(data_obj.shape, (2, 5))
+
+    def test_shape_list(self):
+        """
+        Test that shape works for np.array
+        """
+        data_obj = Data('my_data', [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
+        self.assertTupleEqual(data_obj.shape, (2, 5))
+
 
 if __name__ == '__main__':
     unittest.main()