Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion zarr/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions zarr/tests/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 2 additions & 0 deletions zarr/tests/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
eq(hasattr(g1, '__unexistingattribute__'), False)
Copy link
Member

@alimanfoo alimanfoo Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor nit-pick: it would be slightly more direct to use assert_false(hasattr(g1, '__unexistingattribute__')).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem, changed accordingly.


def test_group_repr(self):
g = self.create_group()
Expand Down