mljs / spectra-processing Goto Github PK
View Code? Open in Web Editor NEWVarious methods to help spectra processing
Home Page: https://mljs.github.io/spectra-processing/
License: MIT License
Various methods to help spectra processing
Home Page: https://mljs.github.io/spectra-processing/
License: MIT License
There is probably no reason some methods can accept specifically Uint16Array. Either we accept any array of number of we only accept DoubleArray.
I just added in cheminfo-types the type NumberArray. We should now check and replace the code where Uint16Array is specified to check if it can be replaced by NumberArray.
https://github.com/cheminfo/cheminfo-types/blob/main/src/core/NumberArray.d.ts
In:
https://github.com/mljs/spectra-processing/blob/master/src/x/xMaxIndex.ts
https://github.com/mljs/spectra-processing/blob/master/src/x/xMinIndex.ts
Allow to have the from / to / fromIndex / toIndex like in:
https://github.com/mljs/spectra-processing/blob/master/src/x/xMaxValue.ts
What you would need to do:
This is a typescript project and is therefore a little bit different from javascript but I think you could manage.
After cloning the project don't forget:
npm i
npx jest --watch
The parameters are confusing and not intuitive
https://github.com/mljs/spectra-processing/blob/master/src/utils/createXArray.ts
We should probably create more than one method. One with step and the other one with fill. I don't see the point with step to ignore from or to.
This is related to #124
No idea for the names. @aiday-mar a proposal ?
In case the data is not a power of 2 Hilbert transform could use xSampling but this should be an option. I don't think that it will be 100% the same result if you go through power of 2 (to be checked).
If it is not 100% please add an option 'forceFFT' that is only useful if it is not a power of 2 and we use xSampling.
In order to be able to describe the documentation of optional parameters with their default value we should either describe them 'inline' or create a new type in which we take the name of the method and append 'Options'. Like for example: XFindClosestIndexOptions.
If you have only 1 to 3 options it is possible to describe them inline but otherwise the new type is required. Same is true when the same type is reused in many functions.
Here is an example of inline help:
And the corresponding result in which we see the default value
Please could you go through all the code to fix similar problems ?
isMonotone
to isMonotonic
and make it return a number:
0
-> not monotonic1
-> monotonic increasing-1
-> monotonic decreasing1
?isMonotoneIncreasing
functionGet inspired by https://stackoverflow.com/questions/14058340/adding-noise-to-a-signal-in-python
We should be able to create an array containing random number
As testcase we could use xNoiseStandardDeviation.
@aiday-mar Could you propose an API and options for this new function ?
I don't know if it is an isolated case but we don't need a help for the property of a parameter that has a specific interface. The help is at the level of the definition of the interface.
Also if we don't have a description of the parameter there is no reason to add an @param
@wadjih-bencheikh18 could you have a look if there are similar problems ?
We are using typedoc to generate the documentation in typescript projects.
When describing a parameter the -
is mandatory otherwise the description does not appear in the documentation.
You can always check the documentation locally using:
npm i --global typedoc
typedoc src/index.ts
Example of modified code:
Example of resulting help
@wadjih-bencheikh18 Please could you have a look through all the code to fix similar problems ?
If a method returns for sure a Float64Array we should not say it returns a DoubleArray
but specify it is a Float64Array
export function xSubtract(
array1: DoubleArray,
array2: DoubleArray | number,
): DoubleArray {
xSampling(array, options)
options:
Other ideas:
https://numpy.org/doc/stable/reference/generated/numpy.logspace.html
https://numpy.org/doc/stable/reference/generated/numpy.linspace.html
Seems there are no tests for this function
https://github.com/mljs/spectra-processing/blob/master/src/utils/numberSort.ts
With the default action to build the documentation I have the following error:
https://github.com/mljs/spectra-processing/runs/2499211793?check_suite_focus=true#step:3:4
In order to let it work I had to add the following 2 lines
What am I doing wrong ? I would expect that the default action works.
We try to have too many options in this method and I think it should be split in 2 methods. The current code is pretty complex.
spectra-processing/src/x/xSequentialFill.ts
Lines 23 to 26 in 220f6ce
xSequentialFillFromTo(from, to, size, {ArrayConstructor})
xSequentialFillFromStep(from, step, size, {ArrayConstructor})
Both methods will return a Float64Array or the output if it has been provided.
Should accept an array of NumberArray and returns an object:
{
q1: [],
median: [],
q3: [],
min: [],
max: [],
};
The variables assigned here are not used after the assignment:
spectra-processing/src/x/xNoiseSanPlot.ts
Lines 160 to 161 in 5cd995e
/cc @lpatiny @wadjih-bencheikh18 who worked on this code.
spectra-processing/src/xy/xyIntegral.ts
Line 44 in c39ed5d
Similar to 5f9aae3
@jobo322 Could you check the problem of the failing tests ?
https://travis-ci.com/github/mljs/spectra-processing/jobs/396368547#L367-L375
If step
parameter is given we would ignore 'to'
@aiday-mar could you add a test that actually checks that it is a gaussian distribution with the correct SD ?
I changed the code so that it is seeded random number to avoid problems with the test.
You could create an histogram (with xHistogram) and use as developper dependency http://mljs.github.io/spectra-fitting/
to check if it match a gaussian.
@lpatiny I made a mistake
Add a function allowing phase correction. What is the best name for this mathematical operation ? Phase correction seems quite NMR specific
In order to ensure that the method is really exposed by the package we should directly use the method from index.ts
One of the only code not being tested is reimAutoPhaseCorrection
@jobo322 could you add a test ?
@lpatiny In a special case, downSampling method removes points from the end when the number of points doesn't evenly divide the array length. This significantly impacts the Hilbert transform's result when using the forceFFT option.
If possible we should replace new Array by new Float64Array and adapt the tests.
Please note that new Float64Array fill by default the array by '0' !!!! No need to fill them.
Get inspired by:
Name the new function xyMassCenter
Don't forget to add the export in xy/index.ts
Add in the previous method @deprecated Please use xyMassCenter
Before you start please have a loot at:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.