Skip to content

Commit

Permalink
inspect kwargs for better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranAngevaare committed Mar 12, 2021
1 parent b5c9474 commit 4250ae5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions strax/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,10 @@ def get_array(self, run_id: ty.Union[str, tuple, list],
{get_docs}
"""
run_ids = strax.to_str_tuple(run_id)

if kwargs.get('allow_multiple', False):
raise RuntimeError('Cannot allow_multiple with get_array/get_df')

if len(run_ids) > 1:
results = strax.multi_run(
self.get_array, run_ids, targets=targets,
Expand All @@ -1132,7 +1136,6 @@ def get_array(self, run_id: ty.Union[str, tuple, list],
targets,
save=save,
max_workers=max_workers,
allow_multiple=False,
**kwargs)
results = [x.data for x in source]

Expand Down Expand Up @@ -1183,6 +1186,9 @@ def accumulate(self,
n_chunks: number of chunks in run
n_rows: number of data entries in run
"""
if kwargs.get('allow_multiple', False):
raise RuntimeError('Cannot allow_multiple with accumulate')

n_chunks = 0
seen_data = False
result = {'n_rows': 0}
Expand All @@ -1194,7 +1200,6 @@ def function(arr):
function_takes_fields = False

for chunk in self.get_iter(run_id, targets,
allow_multiple=False,
**kwargs):
data = chunk.data
data = self._apply_function(data, targets)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def test_allow_multiple(targets=('peaks', 'records')):
function(run_id=run_id,
allow_multiple=True,
targets=targets)
except TypeError:
except RuntimeError:
# Great, this doesn't work (and it shouldn't!)
continue
raise ValueError(f'{function} could run with allow_multiple')
Expand Down

0 comments on commit 4250ae5

Please sign in to comment.