Skip to content

Commit

Permalink
Tests for MemberData.retrieve and _CollectionBase.map finished.
Browse files Browse the repository at this point in the history
Also fixed Bundle such that it has an empty structured array backend on
init.

Closes #8 and #17.
  • Loading branch information
dotsdl committed Jul 7, 2015
1 parent 5f78e85 commit 690560c
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 344 deletions.
4 changes: 2 additions & 2 deletions mdsynthesis/core/aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,9 @@ def dict2multiindex(agg):

# get indexer from *by* keyword
if by == 'uuid':
def get_index(member): member.uuid
def get_index(member): return member.uuid
elif by == 'name':
def get_index(member): member.name
def get_index(member): return member.name
names = [member.name for member in self._members]
if len(set(names)) != len(names):
self._members._logger.warning(
Expand Down
12 changes: 9 additions & 3 deletions mdsynthesis/core/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,13 @@ class _BundleBackend():
def __init__(self):
# our table will be a structured array matching the schema of the
# GroupFile _Members Table
self.table = None
self.table = np.array(
[],
dtype={'names': ['uuid', 'containertype', 'abspath'],
'formats': ['a{}'.format(persistence.uuidlength),
'a{}'.format(persistence.namelength),
'a{}'.format(persistence.pathlength)]
}).reshape(1, -1)

def _member2record(self, uuid, containertype, basedir):
"""Return a record array from a member's information.
Expand Down Expand Up @@ -284,7 +290,7 @@ def add_member(self, uuid, containertype, basedir):
basedir of the new member in the filesystem
"""
if self.table is None:
if self.table.shape == (1, 0):
self.table = self._member2record(uuid, containertype, basedir)
else:
# check if uuid already present
Expand All @@ -311,7 +317,7 @@ def del_member(self, *uuid, **kwargs):
purge = kwargs.pop('all', False)

if purge:
self.table = None
self.__init__()
else:
# remove redundant uuids from given list if present
uuids = set([str(uid) for uid in uuid])
Expand Down
Loading

0 comments on commit 690560c

Please sign in to comment.