Skip to content

Commit

Permalink
ref: minor speed-up for QueueCollectorThread
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Aug 13, 2024
1 parent 10d9865 commit 4c4ca00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.25.1
- ref: replace np.string_ with np.bytes_
- ref: remove unused `data` argument to QueueCollectorThread
- ref: minor speed-up for QueueCollectorThread
0.25.0
- feat: identify flickering in raw data via dcnum.read.detect_flickering
- fix: handle out-of-bounds slice indexing for BaseImageChunkCache
Expand Down
11 changes: 6 additions & 5 deletions src/dcnum/write/queue_collector_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ def add_events(self, index, events):
Event dictionary
"""
idx_loc = index - self.index_offset
idx_stop = self.nev_idx[idx_loc]
self._tracker[idx_loc] = True

if events:
slice_loc = None
idx_stop = self.nev_idx[idx_loc]
for feat in events:
dev = events[feat]
if dev.size:
Expand All @@ -74,6 +73,8 @@ def add_events(self, index, events):
if slice_loc:
self.indices_for_data[slice_loc] = index

self._tracker[idx_loc] = True

def require_feature(self, feat, sample_data):
"""Create a new empty feature array in `self.events` and return it
Expand All @@ -85,10 +86,10 @@ def require_feature(self, feat, sample_data):
Sample data for one event of the feature (used to determine
shape and dtype of the feature array)
"""
sample_data = np.array(sample_data)
event_shape = sample_data.shape
dtype = sample_data.dtype
if feat not in self.events:
sample_data = np.array(sample_data)
event_shape = sample_data.shape
dtype = sample_data.dtype
darr = np.zeros((self.size,) + tuple(event_shape),
dtype=dtype)
self.events[feat] = darr
Expand Down

0 comments on commit 4c4ca00

Please sign in to comment.