Skip to content

Commit 7800cf4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6a6e284 commit 7800cf4

21 files changed

Lines changed: 107 additions & 100 deletions

strax/context.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import strax
1919
from strax import CutList
2020

21-
2221
export, __all__ = strax.exporter()
2322
__all__.extend(["RUN_DEFAULTS_KEY"])
2423

@@ -1460,8 +1459,9 @@ def _add_saver(
14601459
target_plugin: strax.Plugin,
14611460
combining: bool = False,
14621461
):
1463-
"""Adds savers to already existing savers. Checks if data_type can be stored in any storage
1464-
frontend.
1462+
"""Adds savers to already existing savers.
1463+
1464+
Checks if data_type can be stored in any storage frontend.
14651465
14661466
:param savers: Dictionary of already existing savers.
14671467
:param d_to_save: String of the data_type to be saved.
@@ -1576,7 +1576,6 @@ def to_absolute_time_range(
15761576
:param full_range: If True returns full time_range of the run.
15771577
15781578
"""
1579-
15801579
selection = (
15811580
(time_range is None)
15821581
+ (seconds_range is None)
@@ -1624,9 +1623,8 @@ def get_iter(
16241623
) -> ty.Iterator[strax.Chunk]:
16251624
"""Compute target for run_id and iterate over results.
16261625
1627-
Do NOT interrupt the iterator (i.e. break): it will keep running stuff
1628-
in background threads...
1629-
{get_docs}
1626+
Do NOT interrupt the iterator (i.e. break): it will keep running stuff in background
1627+
threads... {get_docs}
16301628
16311629
"""
16321630
if hasattr(run_id, "decode"):
@@ -1837,9 +1835,9 @@ def make(
18371835
combining=False,
18381836
**kwargs,
18391837
) -> None:
1840-
"""Compute target for run_id. Returns nothing (None).
1838+
"""Compute target for run_id.
18411839
1842-
{get_docs}
1840+
Returns nothing (None). {get_docs}
18431841
18441842
"""
18451843
kwargs.setdefault("progress_bar", False)
@@ -2035,9 +2033,11 @@ def get_zarr(
20352033
overwrite=True,
20362034
**kwargs,
20372035
):
2038-
"""Get persistent arrays using zarr. This is useful when loading large amounts of data that
2039-
cannot fit in memory zarr is very compatible with dask. Targets are loaded into separate
2040-
arrays and runs are merged. the data is added to any existing data in the storage location.
2036+
"""Get persistent arrays using zarr.
2037+
2038+
This is useful when loading large amounts of data that cannot fit in memory zarr is very
2039+
compatible with dask. Targets are loaded into separate arrays and runs are merged. the data
2040+
is added to any existing data in the storage location.
20412041
20422042
:param run_ids: (Iterable) run ids you wish to load.
20432043
:param targets: (Iterable) targets to load.
@@ -2087,9 +2087,10 @@ def get_zarr(
20872087
return group
20882088

20892089
def key_for(self, run_id, target, chunk_number=None, combining=False):
2090-
"""Get the DataKey for a given run and a given target plugin. The DataKey is inferred from
2091-
the plugin lineage. The lineage can come either from the _fixed_plugin_cache or computed on
2092-
the fly.
2090+
"""Get the DataKey for a given run and a given target plugin.
2091+
2092+
The DataKey is inferred from the plugin lineage. The lineage can come either from the
2093+
_fixed_plugin_cache or computed on the fly.
20932094
20942095
:param run_id: run id to get
20952096
:param target: data type to get
@@ -2510,7 +2511,6 @@ def merge_per_chunk_storage(
25102511
check_is_stored: bool = True,
25112512
):
25122513
"""Merge the per-chunked data from the per-chunked dependency into the target storage."""
2513-
25142514
if check_is_stored and self.is_stored(run_id, target):
25152515
raise ValueError(f"Data {target} for {run_id} already exists.")
25162516

@@ -2894,7 +2894,6 @@ def tree_levels(self):
28942894
'class': 'Peaks', 'index': 0, 'order': 1}}
28952895
28962896
"""
2897-
28982897
context_hash = self._context_hash()
28992898
if self._fixed_level_cache is not None and context_hash in self._fixed_level_cache:
29002899
return self._fixed_level_cache[context_hash]

strax/dtypes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""Fundamental dtypes for use in strax.
22
3-
Note that if you change the dtype titles (comments), numba will crash if
4-
there is an existing numba cache. Clear __pycache__ and restart.
5-
TODO: file numba issue.
3+
Note that if you change the dtype titles (comments), numba will crash if there is an existing numba
4+
cache. Clear __pycache__ and restart. TODO: file numba issue.
65
76
"""
87

@@ -12,7 +11,6 @@
1211
import numba # noqa: F401
1312
import strax
1413

15-
1614
__all__ = (
1715
"interval_dtype raw_record_dtype record_dtype hit_dtype peak_dtype "
1816
"DIGITAL_SUM_WAVEFORM_CHANNEL DEFAULT_RECORD_LENGTH "
@@ -134,8 +132,9 @@ def hitlet_dtype():
134132

135133

136134
def hitlet_with_data_dtype(n_samples=2):
137-
"""Hitlet dtype with data field. Required within the plugins to compute hitlet properties.
135+
"""Hitlet dtype with data field.
138136
137+
Required within the plugins to compute hitlet properties.
139138
:param n_samples: Buffer length of the data field. Make sure it can hold the longest hitlet.
140139
141140
"""
@@ -246,8 +245,9 @@ def peak_dtype(
246245
def copy_to_buffer(
247246
source: np.ndarray, buffer: np.ndarray, func_name: str, field_names: Optional[Tuple[str]] = None
248247
):
249-
"""Copy the data from the source to the destination e.g. raw_records to records. To this end, we
250-
dynamically create the njitted function with the name 'func_name' (should start with "_").
248+
"""Copy the data from the source to the destination e.g. raw_records to records.
249+
250+
To this end, we dynamically create the njitted function with the name 'func_name' (should start with "_").
251251
252252
:param source: array of input
253253
:param buffer: array of buffer to fill with values from input

strax/plugins/plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,9 @@ def source_finished(self):
408408
raise RuntimeError("source_finished called on a regular plugin")
409409

410410
def _fetch_chunk(self, d, iters, check_end_not_before=None):
411-
"""Add a chunk of the datatype d to the input buffer. Return True if this succeeded, False
412-
if the source is exhausted.
411+
"""Add a chunk of the datatype d to the input buffer.
412+
413+
Return True if this succeeded, False if the source is exhausted.
413414
414415
:param d: data type to fetch
415416
:param iters: iterators that produce data

strax/processing/general.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ class NoBreakFound(Exception):
123123
@export
124124
@numba.njit(nogil=True, cache=True)
125125
def _find_break_i(data, safe_break, not_before):
126-
"""Return first index of element right of the first gap larger than safe_break in data. Assumes
127-
all x have the same length and are sorted!
126+
"""Return first index of element right of the first gap larger than safe_break in data.
127+
128+
Assumes all x have the same length and are sorted!
128129
129130
:param tolerant: if no break found, yield an as good as possible break anyway.
130131
@@ -211,8 +212,9 @@ def _fc_in(a_starts, b_starts, a_ends, b_ends, result):
211212

212213
@export
213214
def split_by_containment(things, containers):
214-
"""Return list of thing-arrays contained in each container. Result is returned as a
215-
numba.typed.List or list if containers are empty.
215+
"""Return list of thing-arrays contained in each container.
216+
217+
Result is returned as a numba.typed.List or list if containers are empty.
216218
217219
Assumes everything is sorted, and containers are non-overlapping.
218220

strax/processing/hitlets.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ def create_hitlets_from_hits(
2323
:param hits: Hits found in records.
2424
:param save_outside_hits: Tuple with left and right hit extension.
2525
:param channel_range: Detectors change range from channel map.
26-
:param chunk_start: (optional) start time of a chunk. Ensures that
27-
no hitlet is earlier than this timestamp.
28-
:param chunk_end: (optional) end time of a chunk. Ensures that
29-
no hitlet ends later than this timestamp.
30-
26+
:param chunk_start: (optional) start time of a chunk. Ensures that no hitlet is earlier than
27+
this timestamp.
28+
:param chunk_end: (optional) end time of a chunk. Ensures that no hitlet ends later than this
29+
timestamp.
3130
:return: Hitlets with temporary fields (data, max_goodness_of_split...)
3231
3332
"""

strax/processing/peak_building.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ def store_downsampled_waveform(
157157
waveform in the peak.
158158
159159
"""
160-
161160
n_samples = len(p["data"])
162161

163162
p_length = p["length"]
@@ -255,9 +254,11 @@ def sum_waveform(
255254
store_data_start=False,
256255
select_peaks_indices=None,
257256
):
258-
"""Compute sum waveforms for all peaks in peaks. Only builds summed waveform other regions in
259-
which hits were found. This is required to avoid any bias due to zero-padding and baselining.
260-
Will downsample sum waveforms if they do not fit in per-peak buffer.
257+
"""Compute sum waveforms for all peaks in peaks.
258+
259+
Only builds summed waveform other regions in which hits were found. This is required to avoid
260+
any bias due to zero-padding and baselining. Will downsample sum waveforms if they do not fit in
261+
per-peak buffer.
261262
262263
:param peaks: Peaks for which the summed waveform should be build.
263264
:param hits: Hits which are inside peaks. Must be sorted according to record_i.
@@ -401,8 +402,9 @@ def sum_waveform(
401402

402403
@numba.njit(cache=True, nogil=True)
403404
def _build_hit_waveform(hit, record, hit_waveform):
404-
"""Adds information for overlapping record and hit to hit_waveform. Updates hit_waveform
405-
inplace. Result is still in ADC counts.
405+
"""Adds information for overlapping record and hit to hit_waveform.
406+
407+
Updates hit_waveform inplace. Result is still in ADC counts.
406408
407409
:return: Boolean if record saturated within the hit.
408410
@@ -477,8 +479,9 @@ def find_hit_integration_bounds(
477479
n_channels,
478480
allow_bounds_beyond_records=False,
479481
):
480-
"""Update (lone) hits to include integration bounds. Please note that time and length of the
481-
original hit are not changed!
482+
"""Update (lone) hits to include integration bounds.
483+
484+
Please note that time and length of the original hit are not changed!
482485
483486
:param hits: Hits or lone hits which should be extended by integration bounds.
484487
:param excluded_intervals: Regions in which hits should not extend to. E.g. Peaks for lone hits.

strax/processing/peak_merging.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def merge_peaks(
3636
constituent peaks, it being too time-consuming to revert to records/hits.
3737
3838
"""
39-
4039
new_peaks, endtime = _merge_peaks(
4140
peaks,
4241
start_merge_at,

strax/processing/peak_properties.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ def compute_widths(peaks):
7777
:param peaks: single strax peak(let) or other data-bearing dtype
7878
7979
"""
80-
8180
desired_widths = np.linspace(0, 1, len(peaks[0]["width"]))
8281
# 0% are width is 0 by definition, and it messes up the calculation below
8382
desired_widths = desired_widths[1:]
@@ -137,8 +136,8 @@ def compute_area_fraction_top(peaks, n_top_channels):
137136

138137
@export
139138
def compute_properties(peaks, n_top_channels=0, select_peaks_indices=None):
140-
"""Compute properties: median_time, width, area_decile_from_midpoint,
141-
center_time, and area_fraction_top for peaks.
139+
"""Compute properties: median_time, width, area_decile_from_midpoint, center_time, and
140+
area_fraction_top for peaks.
142141
143142
:param peaks: single strax peak(let) or other data-bearing dtype
144143
:param select_peaks_indices: array of integers informing which peaks to compute default to None

strax/processing/pulse_processing.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
def baseline(
2121
records, baseline_samples=40, flip=True, allow_sloppy_chunking=False, fallback_baseline=16000
2222
):
23-
"""Determine baseline as the average of the first baseline_samples of each pulse. Subtract the
24-
pulse data from int(baseline), and store the baseline mean and rms.
23+
"""Determine baseline as the average of the first baseline_samples of each pulse.
24+
25+
Subtract the pulse data from int(baseline), and store the baseline mean and rms.
2526
2627
:param baseline_samples: number of samples at start of pulse to average to determine the
2728
baseline.
@@ -165,8 +166,9 @@ def find_hits(
165166
min_amplitude: ty.Union[int, np.ndarray] = 15,
166167
min_height_over_noise: ty.Union[int, np.ndarray] = 0,
167168
):
168-
"""Return hits (intervals >= threshold) found in records. Hits that straddle record boundaries
169-
are split (perhaps we should fix this?)
169+
"""Return hits (intervals >= threshold) found in records.
170+
171+
Hits that straddle record boundaries are split (perhaps we should fix this?)
170172
171173
NB: returned hits are NOT sorted yet!
172174
@@ -316,8 +318,9 @@ def _waveforms_to_float(wv, bl):
316318

317319
@export
318320
def filter_records(r, ir):
319-
"""Apply filter with impulse response ir over the records r. Assumes the filter origin is at the
320-
impulse response maximum.
321+
"""Apply filter with impulse response ir over the records r.
322+
323+
Assumes the filter origin is at the impulse response maximum.
321324
322325
:param ws: Waveform matrix, must be float
323326
:param ir: Impulse response, must have odd length. Will normalize.
@@ -338,8 +341,9 @@ def filter_records(r, ir):
338341

339342
@export
340343
def filter_waveforms(ws, ir, prev_r, next_r):
341-
"""Convolve filter with impulse response ir over each row of ws. Assumes the filter origin is at
342-
the impulse response maximum.
344+
"""Convolve filter with impulse response ir over each row of ws.
345+
346+
Assumes the filter origin is at the impulse response maximum.
343347
344348
:param ws: Waveform matrix, must be float
345349
:param ir: Impulse response, must have odd length.

strax/run_selection.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def list_available(self, target, runs=None, **kwargs) -> list:
2626
:param runs: Runs to check. If None, check all runs.
2727
2828
"""
29-
3029
if len(kwargs):
3130
# noinspection PyMethodFirstArgAssignment
3231
self = self.new_context(**kwargs)
@@ -53,8 +52,10 @@ def list_available(self, target, runs=None, **kwargs) -> list:
5352
def keys_for_runs(
5453
self, target: str, run_ids: ty.Union[np.ndarray, list, tuple, str]
5554
) -> ty.List[strax.DataKey]:
56-
"""Get the data-keys for a multitude of runs. If use_per_run_defaults is False which it
57-
preferably is (#246), getting many keys should be fast as we only compute the lineage once.
55+
"""Get the data-keys for a multitude of runs.
56+
57+
If use_per_run_defaults is False which it preferably is (#246), getting many keys should be fast
58+
as we only compute the lineage once.
5859
5960
:param run_ids: Runs to get datakeys for
6061
:param target: datatype requested
@@ -467,8 +468,9 @@ def available_for_run(
467468
exclude_targets: ty.Union[None, list, tuple, str] = None,
468469
pattern_type: str = "fnmatch",
469470
) -> pd.DataFrame:
470-
"""For a given single run, check all the targets if they are stored. Excludes the target if
471-
never stored anyway.
471+
"""For a given single run, check all the targets if they are stored.
472+
473+
Excludes the target if never stored anyway.
472474
473475
:param run_id: requested run
474476
:param include_targets: targets to include e.g. raw_records, raw_records* or *_nv. If multiple

0 commit comments

Comments
 (0)