diff --git a/zarr/hierarchy.py b/zarr/hierarchy.py index 31cb062c91..9c92f4b122 100644 --- a/zarr/hierarchy.py +++ b/zarr/hierarchy.py @@ -319,7 +319,10 @@ def _delitem_nosync(self, item): def __getattr__(self, item): # allow access to group members via dot notation - return self.__getitem__(item) + try: + return self.__getitem__(item) + except KeyError: + raise AttributeError def group_keys(self): """Return an iterator over member names for groups only. diff --git a/zarr/tests/test_codecs.py b/zarr/tests/test_codecs.py index 974ba99f2b..7538813e6c 100644 --- a/zarr/tests/test_codecs.py +++ b/zarr/tests/test_codecs.py @@ -149,6 +149,7 @@ def _test_decode_lossy(self, arr, decimal, **kwargs): order=order) assert_array_almost_equal(arr, out, decimal=decimal) + test_arrays = [ np.arange(1000, dtype='i4'), np.linspace(1000, 1001, 1000, dtype='f8'), diff --git a/zarr/tests/test_hierarchy.py b/zarr/tests/test_hierarchy.py index fca7093c0b..a13fb29e05 100644 --- a/zarr/tests/test_hierarchy.py +++ b/zarr/tests/test_hierarchy.py @@ -492,6 +492,8 @@ def test_getattr(self): # test eq(g1['foo'], g1.foo) eq(g2['bar'], g2.bar) + # test that hasattr returns False instead of an exception (issue #88) + assert_false(hasattr(g1, 'unexistingattribute')) def test_group_repr(self): g = self.create_group()