feat(tag): add Tag.cumulativeIntegral() trapezoidal totalizer (#327)#331
Draft
HanSur94 wants to merge 3 commits into
Draft
feat(tag): add Tag.cumulativeIntegral() trapezoidal totalizer (#327)#331HanSur94 wants to merge 3 commits into
HanSur94 wants to merge 3 commits into
Conversation
…egrator
- Concrete public method on the Tag base class (not abstract, no Tag:notImplemented)
- Gap-robust: per-segment 0.5*dt*(Y_i+Y_{i+1}), non-finite segments zeroed
so interior NaN does not poison the running tail; identical to cumtrapz
when data is clean (cum(1)=0)
- Single 'Range',[t0 t1] name-value option dispatches to getXYRange()
- Empty series: 1-out -> 0, 2-out -> [],[]
- Single-sample series: cum=0 (no interval = no area)
- Emits Tag:integralOnDiscrete warning for StateTag kind, still returns value
- 1-out form: scalar cum(end); 2-out form: [X, cum] row vectors
- Abstract-stub count unchanged: 6 occurrences of Tag:notImplemented
- testCumulativeIntegralUniformRamp: constant Y=2 over 0:4 -> [0 2 4 6 8] - testCumulativeIntegralNonUniform: X=[0 1 3 7] non-uniform spacing verified - testCumulativeIntegralRangeWindow: 'Range' option derives expected from getXYRange - testCumulativeIntegralScalarForm: 1-out total equals 2-out cum(end) - testCumulativeIntegralEmptyData: MockTag returns 0 (1-out) and [] (2-out) - testCumulativeIntegralNaNGap: interior NaN does not produce NaN tail - testCumulativeIntegralDiscreteWarns: StateTag emits Tag:integralOnDiscrete - testCumulativeIntegralUnknownOption: bogus key throws Tag:unknownOption - Existing testAbstractMethodCount unchanged (still asserts 6 stubs)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was built
Adds a new additive public method
cumulativeIntegral()to the baseTagclass (libs/SensorThreshold/Tag.m), inherited by every Tag subclass through the existinggetXY/getXYRangeseam. Returns the running trapezoidal (area-under-curve) integral of Y w.r.t. X — the totalizer primitive (flow→volume, power→energy, current→charge, dose rate→accumulated dose).Design:
0.5·dt·(Y_i+Y_{i+1})), non-finite segments zeroed, thencumsumwith a leading 0. Algebraically identical tocumtrapz(X,Y)when no NaNs are present; an interior NaN zeroes only its two flanking segments instead of poisoning the entire tail.Tag:integralOnDiscretewarning on a'state'(discrete/ZOH) channel, since area-under-staircase is rarely intended; still returns the value.nargoutdispatch — 2-out returns[X, cum], 1-out returns scalarcum(end). Empty data →0(scalar) /[](series).'Range'parsed in the lib's existing inline name-value style; unknown keys →Tag:unknownOption.Backward-compatible & additive only: no public signature, serialized format,
toStruct/fromStruct, orDashboardWidget/Taginterface change. Toolbox-free, pure MATLAB/Octave, no MEX. The abstract-stub count stays at exactly 6 (the new method is concrete, contains noTag:notImplemented).How it was verified
TestTagsuite: 32/32 pass in the live MATLAB session (8 newcumulativeIntegralcases: ramp area, non-uniform spacing vscumtrapz,'Range'windowing, scalar form, MockTag empty-guard, NaN-gap, discrete-channel warning, unknown-option error).Y=2over0:4→[0 2 4 6 8], total8; interior NaN →[0 0 0 1 2](no NaN tail); empty →0.mh_style+mh_lint: everything seems fine on both changed files.Closes #327
AI-built via
/feature-build— needs human review before merge.