You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering why the main API async simpleSmoothingSpline(data, opts) is asynchronous ?
There is no reason as far as I can imagine for these calculus to be asynchronous. If, for some reason, users of this library do not want to block the UI with costly calculus, it's up to the user to defer this to the next tick.
I'm gonna have a deeper look at the library contents, maybe there is something I am missing ?
The text was updated successfully, but these errors were encountered:
I am just pointing out that many APIs / methods of the code are async while they don't have to.
You can simplify the whole codebase by simply calling Matrix.ready at the beginning of the implementation of smoothingSpline :
exportdefaultasyncfunctionsmoothingSpline(data: Point[],{ lambda =1000, type ="smoothing"}: smoothingSplineOptions={}): Promise<SmoothingSpline>{awaitMatrix.ready;// <=== The only call to an async function.// The rest is not async anymore :letsplineFn: SplineFunction;if(type==="cubic"){splineFn=generateCubicSplineFunction(data);}else{splineFn=generateSmoothingSplineFunction(data,{ lambda });}constsplinePoints=generateSplinePoints(splineFn,data);return{fn: splineFn,points: splinePoints,};}
The implementation of Matrix.ready being the following :
Note that by making these modifications, the workaround described in the Matrix class is not necessary anymore :
// EigenMatrix ops are async so we cannot create _eigenMatrix
// in the constructor. If we're given an array, we'll store it
// in _data and create the matrix when we do our first operation.
I can submit a PR for this, all the tests are passing fine...
Hi !
Nice work, thanks for this library !
I was wondering why the main API
async simpleSmoothingSpline(data, opts)
is asynchronous ?There is no reason as far as I can imagine for these calculus to be asynchronous. If, for some reason, users of this library do not want to block the UI with costly calculus, it's up to the user to defer this to the next tick.
I'm gonna have a deeper look at the library contents, maybe there is something I am missing ?
The text was updated successfully, but these errors were encountered: