Skip to content

Commit

Permalink
Merge pull request #23 from yymao/bug/native-filters-no-match
Browse files Browse the repository at this point in the history
return empty ndarray when native filters have no matches
  • Loading branch information
yymao authored Oct 31, 2018
2 parents cb3d532 + 8cdb369 commit 44522ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion GCR/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,19 @@ def get_quantities(self, quantities, filters=None, native_filters=None, return_i
return it

data_all = defaultdict(list)
count = 0
for data in it:
for q in quantities:
data_all[q].append(data[q])
return {q: (np.concatenate(data_all[q]) if len(data_all[q]) > 1 else data_all[q][0]) for q in quantities}
count += 1

if count == 0:
return {q: np.array([]) for q in quantities}

if count == 1:
return dict(data_all)

return {q: np.concatenate(data_all[q]) for q in quantities}

def has_quantity(self, quantity, include_native=True):
"""
Expand Down
2 changes: 1 addition & 1 deletion GCR/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""package version"""
__version__ = '0.8.4'
__version__ = '0.8.5'

0 comments on commit 44522ef

Please sign in to comment.