Repository navigation
Speed up Parameters copy/set_transmits and fix compute_time_to_peak - #656
Conversation
Memoise the dependents search per class, since the dependency graph is fixed; the uncached recursive rescan made copy() of a full Parameters cost about a second. Batch compute_time_to_peak_stack into one call instead of looping per waveform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compute_time_to_peak now takes a scalar or per-waveform center frequency for a stack of waveforms, so the stack variant is removed from the API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe peak-time utility now handles waveform stacks and per-waveform center frequencies. ChangesPeak-Time Calculation
Parameter Dependency Traversal
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
_collect_dependents only scanned cls.__dict__, so subclasses of a parameters class (such as the deprecated Scan) found no dependents and never invalidated their cached properties. The memoised lookup made that permanent per class.
It is part of the public zea.func API, so removing it outright breaks existing imports. Forward it to compute_time_to_peak, which now handles stacks itself.
_find_all_dependents already returns every direct and indirect dependent, but _invalidate recursed into each of them again, re-walking the subtree for every node on each __setattr__.
A size-1 frequency is treated as a scalar, so a single waveform keeps returning a scalar. A per-waveform frequency must match the waveforms' leading shape; mismatches now raise a clear ValueError instead of silently broadcasting or failing deep inside the backend.
functools.cache on the classmethod kept every parameters class it had seen alive for the lifetime of the process. Store the memo in a per-class dict, created in __init_subclass__, so it is freed together with the class.
The instance method had become a one-line wrapper around the memoised classmethod; make _find_all_dependents itself the cached classmethod.
tristan-deep
left a comment
There was a problem hiding this comment.
Nice, is giving me about a 100x speedup for a common Parameters.copy(). Pushed some minor clean-up commits too.
Changes
Parameters.copy()/set_transmits: the dependents search is now cached per class, since the dependency graph doesn't change. Without the cache,copy()of a fullParameterstook about a second.compute_time_to_peak:demodulateran the Hilbert transform over the size-1 channel axis instead of the time axis, sot_peakcame fromargmax(|waveform|)rather than the envelope peak. Added a sine-carrier test case that catches this.compute_time_to_peak: it now handles a stack of waveforms in a single call, with either one center frequency or one per waveform.Breaking
compute_time_to_peak_stack. Usecompute_time_to_peakinstead.Parameters.t_peakvalues estimated fromwaveforms_two_waychange wherever the carrier peak doesn't coincide with the envelope peak.🤖 Generated with Claude Code
Summary by CodeRabbit
Enhancements
Bug Fixes