add xyObjectPivot function and corresponding #294
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #294 +/- ##
==========================================
+ Coverage 96.38% 96.40% +0.01%
==========================================
Files 184 185 +1
Lines 5152 5176 +24
Branches 1147 1155 +8
==========================================
+ Hits 4966 4990 +24
Misses 186 186 ☔ View full report in Codecov by Sentry. |
src/xyObject/xyObjectPivot.ts
Outdated
| const { thresholdFactor = 0.2, fromTo = { from: minX, to: maxX } } = options; | ||
| let { from, to } = fromTo; |
There was a problem hiding this comment.
This approach seems wrong because if you give fromTo={from:1} to will never be defined to the correct value.
But in this project ml-spectra-processing we don't use an object fromTo but 2 properties from and to. Also from / to are the values. If you want to index you need to use fromIndex and toIndex.
You can also allow the 4 parameters and use the helper function:
spectra-processing/src/x/xMinValue.ts
Lines 17 to 18 in 5e5a85a
There was a problem hiding this comment.
but the interface will alert if you pass only from in the object, should I add a guard for this?
There was a problem hiding this comment.
ok, if I assume than x is ordered we could ignore the maxX minX generation, but I need the x value instead of index because the x value is in ppm scale
| const { thresholdFactor = 0.2, fromTo = { from: minX, to: maxX } } = options; | ||
| let { from, to } = fromTo; | ||
|
|
||
| if (from > to) [from, to] = [to, from]; |
There was a problem hiding this comment.
The switch of value is manage by xGetFromToIndex
src/xyObject/xyObjectPivot.ts
Outdated
| } | ||
|
|
||
| /** | ||
| * Finds the index of the peak in an array of points (x, y) based on a threshold factor in Y values and a specified range in X values. |
There was a problem hiding this comment.
I don't understand what this method does. What is special with this peak is not written in the description and you return only one.
… instead of index and adjust tests accordingly
No description provided.