Skip to content

Commit

Permalink
Fixes #21; can now getitem datasets with a list of names.
Browse files Browse the repository at this point in the history
  • Loading branch information
dotsdl committed Apr 9, 2015
1 parent 356b275 commit a4742a7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mdsynthesis/core/aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,19 +864,29 @@ def inner(self, handle, *args, **kwargs):
return inner

def __getitem__(self, handle):
"""Get dataset corresponding to given handle.
"""Get dataset corresponding to given handle(s).
If dataset doesn't exist, ``None`` is returned.
:Arguments:
*handle*
name of data to retrieve
name of data to retrieve; may also be a list of names
:Returns:
*data*
stored data; ``None`` if nonexistent
stored data; if *handle* was a list, will be a list
of equal length with the stored data as members; will yield
``None`` if requested data is nonexistent
"""
return self.retrieve(handle)
if isinstance(handle, list):
out = list()
for item in handle:
out.append(self.retrieve(item))
elif isinstance(handle, basestring):
out = self.retrieve(handle)

return out

def __setitem__(self, handle, data):
"""Set dataset corresponding to given handle.
Expand Down

0 comments on commit a4742a7

Please sign in to comment.