Skip to content

Commit 64153f8

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9b598bd commit 64153f8

19 files changed

Lines changed: 57 additions & 73 deletions

strax/context.py

Lines changed: 9 additions & 13 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

@@ -1443,8 +1442,8 @@ def _add_saver(
14431442
target_plugin: strax.Plugin,
14441443
combining: bool = False,
14451444
):
1446-
"""Adds savers to already existing savers. Checks if data_type can be stored in any storage
1447-
frontend.
1445+
"""Adds savers to already existing savers. frontend. Checks if data_type can be stored in
1446+
any storage.
14481447
14491448
:param savers: Dictionary of already existing savers.
14501449
:param d_to_save: String of the data_type to be saved.
@@ -1559,7 +1558,6 @@ def to_absolute_time_range(
15591558
:param full_range: If True returns full time_range of the run.
15601559
15611560
"""
1562-
15631561
selection = (
15641562
(time_range is None)
15651563
+ (seconds_range is None)
@@ -1820,9 +1818,9 @@ def make(
18201818
combining=False,
18211819
**kwargs,
18221820
) -> None:
1823-
"""Compute target for run_id. Returns nothing (None).
1821+
"""Compute target for run_id.
18241822
1825-
{get_docs}
1823+
Returns nothing (None). {get_docs}
18261824
18271825
"""
18281826
kwargs.setdefault("progress_bar", False)
@@ -2018,8 +2016,8 @@ def get_zarr(
20182016
overwrite=True,
20192017
**kwargs,
20202018
):
2021-
"""Get persistent arrays using zarr. This is useful when loading large amounts of data that
2022-
cannot fit in memory zarr is very compatible with dask. Targets are loaded into separate
2019+
"""Get persistent arrays using zarr. cannot fit in memory zarr is very compatible with dask.
2020+
Targets are loaded into separate This is useful when loading large amounts of data that
20232021
arrays and runs are merged. the data is added to any existing data in the storage location.
20242022
20252023
:param run_ids: (Iterable) run ids you wish to load.
@@ -2070,9 +2068,9 @@ def get_zarr(
20702068
return group
20712069

20722070
def key_for(self, run_id, target, chunk_number=None, combining=False):
2073-
"""Get the DataKey for a given run and a given target plugin. The DataKey is inferred from
2074-
the plugin lineage. The lineage can come either from the _fixed_plugin_cache or computed on
2075-
the fly.
2071+
"""Get the DataKey for a given run and a given target plugin. the plugin lineage. The
2072+
lineage can come either from the _fixed_plugin_cache or computed on The DataKey is inferred
2073+
from the fly.
20762074
20772075
:param run_id: run id to get
20782076
:param target: data type to get
@@ -2487,7 +2485,6 @@ def merge_per_chunk_storage(
24872485
check_is_stored: bool = True,
24882486
):
24892487
"""Merge the per-chunked data from the per-chunked dependency into the target storage."""
2490-
24912488
if check_is_stored and self.is_stored(run_id, target):
24922489
raise ValueError(f"Data {target} for {run_id} already exists.")
24932490

@@ -2871,7 +2868,6 @@ def tree_levels(self):
28712868
'class': 'Peaks', 'index': 0, 'order': 1}}
28722869
28732870
"""
2874-
28752871
context_hash = self._context_hash()
28762872
if self._fixed_level_cache is not None and context_hash in self._fixed_level_cache:
28772873
return self._fixed_level_cache[context_hash]

strax/dtypes.py

Lines changed: 6 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,8 @@ 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. dynamically
249+
create the njitted function with the name 'func_name' (should start with "_"). To this end, we.
251250
252251
:param source: array of input
253252
:param buffer: array of buffer to fill with values from input

strax/plugins/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ def source_finished(self):
411411
raise RuntimeError("source_finished called on a regular plugin")
412412

413413
def _fetch_chunk(self, d, iters, check_end_not_before=None):
414-
"""Add a chunk of the datatype d to the input buffer. Return True if this succeeded, False
415-
if the source is exhausted.
414+
"""Add a chunk of the datatype d to the input buffer. if the source is exhausted. Return
415+
True if this succeeded, False.
416416
417417
:param d: data type to fetch
418418
:param iters: iterators that produce data

strax/processing/general.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ 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. all x
127+
have the same length and are sorted! Assumes.
128128
129129
:param tolerant: if no break found, yield an as good as possible break anyway.
130130
@@ -211,8 +211,8 @@ def _fc_in(a_starts, b_starts, a_ends, b_ends, result):
211211

212212
@export
213213
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.
214+
"""Return list of thing-arrays contained in each container. numba.typed.List or list if
215+
containers are empty. Result is returned as a.
216216
217217
Assumes everything is sorted, and containers are non-overlapping.
218218

strax/processing/peak_building.py

Lines changed: 6 additions & 7 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,8 +254,8 @@ 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.
257+
"""Compute sum waveforms for all peaks in peaks. which hits were found. This is required to
258+
avoid any bias due to zero-padding and baselining. Only builds summed waveform other regions in
260259
Will downsample sum waveforms if they do not fit in per-peak buffer.
261260
262261
:param peaks: Peaks for which the summed waveform should be build.
@@ -401,8 +400,8 @@ def sum_waveform(
401400

402401
@numba.njit(cache=True, nogil=True)
403402
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.
403+
"""Adds information for overlapping record and hit to hit_waveform. inplace. Result is still in
404+
ADC counts. Updates hit_waveform.
406405
407406
:return: Boolean if record saturated within the hit.
408407
@@ -477,8 +476,8 @@ def find_hit_integration_bounds(
477476
n_channels,
478477
allow_bounds_beyond_records=False,
479478
):
480-
"""Update (lone) hits to include integration bounds. Please note that time and length of the
481-
original hit are not changed!
479+
"""Update (lone) hits to include integration bounds. original hit are not changed! Please note
480+
that time and length of the.
482481
483482
:param hits: Hits or lone hits which should be extended by integration bounds.
484483
: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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
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. pulse data
24+
from int(baseline), and store the baseline mean and rms. Subtract the.
2525
2626
:param baseline_samples: number of samples at start of pulse to average to determine the
2727
baseline.
@@ -165,8 +165,8 @@ def find_hits(
165165
min_amplitude: ty.Union[int, np.ndarray] = 15,
166166
min_height_over_noise: ty.Union[int, np.ndarray] = 0,
167167
):
168-
"""Return hits (intervals >= threshold) found in records. Hits that straddle record boundaries
169-
are split (perhaps we should fix this?)
168+
"""Return hits (intervals >= threshold) found in records. are split (perhaps we should fix
169+
this?) Hits that straddle record boundaries.
170170
171171
NB: returned hits are NOT sorted yet!
172172
@@ -316,8 +316,8 @@ def _waveforms_to_float(wv, bl):
316316

317317
@export
318318
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.
319+
"""Apply filter with impulse response ir over the records r. impulse response maximum. Assumes
320+
the filter origin is at the.
321321
322322
:param ws: Waveform matrix, must be float
323323
:param ir: Impulse response, must have odd length. Will normalize.
@@ -338,8 +338,8 @@ def filter_records(r, ir):
338338

339339
@export
340340
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.
341+
"""Convolve filter with impulse response ir over each row of ws. the impulse response maximum.
342+
Assumes the filter origin is at.
343343
344344
:param ws: Waveform matrix, must be float
345345
:param ir: Impulse response, must have odd length.

strax/run_selection.py

Lines changed: 4 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,8 @@ 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. preferably is (#246), getting many keys should be
56+
fast as we only compute the lineage once. If use_per_run_defaults is False which it.
5857
5958
:param run_ids: Runs to get datakeys for
6059
:param target: datatype requested
@@ -467,8 +466,8 @@ def available_for_run(
467466
exclude_targets: ty.Union[None, list, tuple, str] = None,
468467
pattern_type: str = "fnmatch",
469468
) -> pd.DataFrame:
470-
"""For a given single run, check all the targets if they are stored. Excludes the target if
471-
never stored anyway.
469+
"""For a given single run, check all the targets if they are stored. never stored anyway.
470+
Excludes the target if.
472471
473472
:param run_id: requested run
474473
:param include_targets: targets to include e.g. raw_records, raw_records* or *_nv. If multiple

strax/storage/files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
@export
1919
class DataDirectory(StorageFrontend):
20-
"""Simplest registry: single directory with FileStore data
21-
sitting in subdirectories.
20+
"""Simplest registry: single directory with FileStore data sitting in subdirectories.
2221
2322
Run-level metadata is stored in loose json files in the directory.
23+
2424
"""
2525

2626
can_define_runs = True

0 commit comments

Comments
 (0)