diff --git a/system/dataset.py b/system/dataset.py index 47ed9f7..ad6a617 100644 --- a/system/dataset.py +++ b/system/dataset.py @@ -1,4 +1,4 @@ -from scipy import ndarray,atleast_2d,asarray +from scipy import ndarray,atleast_2d,asarray,intersect1d from scipy import sort as array_sort from itertools import izip import shelve @@ -156,13 +156,13 @@ class Dataset: given dim. Index (Indices) are the Identifiers position in a matrix in a given dim. """ - try: - if len(indices)==0:# if empty list or empty array - indices=[] - except: - pass + if indices!=None: + if len(indices)==0:# if empty list or empty array + return [] if indices != None: + # be sure to match intersection + #indices = intersect1d(self.get_indices(dim),indices) ids = [self._map[dim].reverse[i] for i in indices] else: if sorted==True: @@ -174,7 +174,6 @@ class Dataset: def get_indices(self, dim, idents=None): """Returns indices for identifiers along dimension. - You can optionally provide a list of identifiers to retrieve a index subset. @@ -192,6 +191,8 @@ class Dataset: return asarray(index) def copy(self): + """ Returns deepcopy of dataset. + """ return copy.deepcopy(self)