Skip to content

Commit 36a54ed

Browse files
committed
blackify
1 parent fad8e5c commit 36a54ed

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

flarestack/core/results.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,11 @@ def clean_merged_data(self):
5555
logger.debug(f"Removed all files from {self.merged_path}")
5656

5757
def get_subdirs(self):
58-
return [
59-
x
60-
for x in os.listdir(self.path)
61-
if x[0] != "." and x != "merged"
62-
]
58+
return [x for x in os.listdir(self.path) if x[0] != "." and x != "merged"]
6359

64-
def merge_datadict(self, merged: dict[str, list | dict], pending_data: dict[str, list | dict]):
60+
def merge_datadict(
61+
self, merged: dict[str, list | dict], pending_data: dict[str, list | dict]
62+
):
6563
"""Merge the content of pending_data into merged."""
6664
for key, info in pending_data.items():
6765
if isinstance(info, list):
@@ -81,7 +79,6 @@ def merge_datadict(self, merged: dict[str, list | dict], pending_data: dict[str,
8179
f"Unexpected type for key {key}: {type(info)}. Expected list or dict."
8280
)
8381

84-
8582
def merge_and_load_subdir(self, subdir_name):
8683
"""Merge and load data from a single subdirectory."""
8784
subdir = os.path.join(self.path, subdir_name)
@@ -138,12 +135,12 @@ def merge_and_load(self, output_dict: dict):
138135

139136
if pending_data:
140137
if scale_label == background_label and background_label in output_dict:
138+
logger.info("Appending background data to existing trials.")
141139
self.merge_datadict(output_dict[background_label], pending_data)
142140
else:
143141
output_dict[scale_label] = pending_data
144142

145143

146-
147144
class ResultsHandler(object):
148145
def __init__(
149146
self,
@@ -152,7 +149,7 @@ def __init__(
152149
do_disc=True,
153150
bias_error="std",
154151
sigma_thresholds=[3.0, 5.0],
155-
background_from=None
152+
background_from=None,
156153
):
157154
self.sources = load_catalogue(rh_dict["catalogue"])
158155

@@ -238,9 +235,7 @@ def __init__(
238235
logger.warning(f"No files found at {self.pickle_output_dir}")
239236

240237
# auxiliary parameters
241-
self.scale_values = sorted(
242-
[float(j) for j in self.results.keys()]
243-
)
238+
self.scale_values = sorted([float(j) for j in self.results.keys()])
244239
self.scale_labels = [scale_shortener(i) for i in self.scale_values]
245240

246241
logger.info(f"Injection scales: {self.scale_values}")
@@ -396,7 +391,6 @@ def clean_merged_data(self):
396391
"""Clean merged data from pickle cache, only for main analysis. Do not touch the background cache."""
397392
self.pickle_cache.clean_merged_data()
398393

399-
400394
def load_injection_values(self):
401395
"""Function to load the values used in injection, so that a
402396
comparison to the fit results can be made.
@@ -423,18 +417,14 @@ def load_injection_values(self):
423417

424418
return inj_values
425419

426-
427420
def merge_and_load_pickle_data(self):
428421
# NOTE:
429422
# self.pickle_output_path
430423
# self.merged_dir = self.pickle_output_path / "merged"
431424

432-
433425
# Loop over all subdirectories, one for each injection scale, containing one pickle per trial.
434426
all_sub_dirs = [
435-
x
436-
for x in os.listdir(self.path)
437-
if x[0] != "." and x != "merged"
427+
x for x in os.listdir(self.path) if x[0] != "." and x != "merged"
438428
]
439429
# Create a "merged" directory, that will contain a single pickle with many trials per injection scale.
440430
try:

0 commit comments

Comments
 (0)