Skip to content

Commit eb67d39

Browse files
committed
replace for loop with numpy indexing
1 parent f1bb527 commit eb67d39

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/sed/loader/mpes/loader.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ def hdf5_to_timed_dataframe(
224224

225225
electron_channels = []
226226
column_names = []
227-
228227
for name, channel in channels.items():
229228
if channel["format"] == "per_electron":
230229
if channel["dataset_key"] in test_proc:
@@ -468,16 +467,13 @@ def hdf5_to_timed_array(
468467
# Delayed array for loading an HDF5 file of reasonable size (e.g. < 1GB)
469468

470469
h5file = load_h5_in_memory(h5filename)
471-
472470
# Read out groups:
473471
data_list = []
474472
ms_marker = np.asarray(h5file[ms_markers_key])
475473
for channel in channels:
476-
timed_dataset = np.zeros_like(ms_marker)
477474
if channel["format"] == "per_electron":
478475
g_dataset = np.asarray(h5file[channel["dataset_key"]])
479-
for i, point in enumerate(ms_marker):
480-
timed_dataset[i] = g_dataset[int(point) - 1]
476+
timed_dataset = g_dataset[np.maximum(ms_marker - 1, 0)]
481477
else:
482478
raise ValueError(
483479
f"Invalid 'format':{channel['format']} for channel {channel['dataset_key']}.",

0 commit comments

Comments
 (0)