Skip to content

Commit

Permalink
Merge pull request #143 from OpenCOMPES/processor_tests
Browse files Browse the repository at this point in the history
Processor tests
  • Loading branch information
rettigl authored Sep 23, 2023
2 parents 9b8cae0 + 7ece180 commit 2b8114c
Show file tree
Hide file tree
Showing 18 changed files with 1,464 additions and 308 deletions.
9 changes: 5 additions & 4 deletions sed/binning/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def bin_partition(
Args:
part (Union[dask.dataframe.DataFrame, pd.DataFrame]): dataframe on which
to perform the histogram. Usually a partition of a dask DataFrame.
bins (int, dict, Sequence[int], Sequence[np.ndarray], Sequence[tuple], optional):
bins (int, dict, Sequence[int], Sequence[np.ndarray], Sequence[tuple], optional):
Definition of the bins. Can be any of the following cases:
- an integer describing the number of bins for all dimensions. This
Expand Down Expand Up @@ -85,7 +85,7 @@ def bin_partition(
jitter={'axis':{'amplitude':0.5,'mode':'uniform'}}.
This example also shows the default behaviour, in case None is
passed in the dictionary, or jitter is a list of strings.
Warning: this is not the most performing approach. applying jitter
Warning: this is not the most performing approach. Applying jitter
on the dataframe before calling the binning is much faster.
Defaults to None.
return_edges (bool, optional): If True, returns a list of D arrays
Expand All @@ -112,7 +112,8 @@ def bin_partition(
bins, axes, ranges = simplify_binning_arguments(bins, axes, ranges)
else:
if not isinstance(bins, list) or not (
all(isinstance(x, int) for x in bins) or all(isinstance(x, np.ndarray) for x in bins)
all(isinstance(x, (int, np.int64)) for x in bins)
or all(isinstance(x, np.ndarray) for x in bins)
):
raise TypeError(
"bins needs to be of type 'List[int] or List[np.ndarray]' if tests are skipped!",
Expand Down Expand Up @@ -157,7 +158,7 @@ def bin_partition(
mode = jpars.get("mode", "uniform")
ax_index = axes.index(col)
_bin = bins[ax_index]
if isinstance(_bin, int):
if isinstance(_bin, (int, np.int64)):
rng = ranges[ax_index]
binsize = abs(rng[1] - rng[0]) / _bin
else:
Expand Down
4 changes: 2 additions & 2 deletions sed/binning/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def simplify_binning_arguments(
bins = bins_

# if bins provided as single int, apply to all dimensions
if isinstance(bins, int):
if isinstance(bins, (int, np.int64)):
bins = [bins] * len(axes)

# Check that we have a sequence of bins now
Expand Down Expand Up @@ -112,7 +112,7 @@ def simplify_binning_arguments(
bins = bins_

# if bins are provided as int, check that ranges are present
if all(isinstance(x, int) for x in bins):
if all(isinstance(x, (int, np.int64)) for x in bins):
bins = cast(List[int], list(bins))
if ranges is None:
raise AttributeError(
Expand Down
2 changes: 1 addition & 1 deletion sed/calibrator/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def append_delay_axis(

if "delay_range" not in calibration.keys():
if "delay_range_mm" not in calibration.keys() or "time0" not in calibration.keys():
if datafile is not None:
if datafile is not None and p1_key and p2_key and t0_key:
try:
ret = extract_delay_stage_parameters(
datafile,
Expand Down
Loading

0 comments on commit 2b8114c

Please sign in to comment.