Skip to content

Commit

Permalink
Check data is non-empty with prod(data.shape) instead of `data.size…
Browse files Browse the repository at this point in the history
…`. Works with sparse arrays and is somehow faster.
  • Loading branch information
cboulay committed Oct 30, 2024
1 parent 2ac51c2 commit 632c85f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ezmsg/sigproc/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import traceback
import typing

Expand Down Expand Up @@ -30,7 +31,7 @@ async def on_settings(self, msg: ez.Settings) -> None:
async def on_signal(self, message: AxisArray) -> typing.AsyncGenerator:
try:
ret = self.STATE.gen.send(message)
if ret.data.size > 0:
if math.prod(ret.data.shape) > 0:
yield self.OUTPUT_SIGNAL, ret
except (StopIteration, GeneratorExit):
ez.logger.debug(f"Generator closed in {self.address}")
Expand Down

0 comments on commit 632c85f

Please sign in to comment.