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
Describe the bug
On functions like mean, min, max, std, if you take some 2d number array and want to aggregate it along the 1 axis to retrieve a 1d array of output, you want to get some kind of array/matrix/vector type back. However, it only returns MathScalarType which causes a typescript error. I believe that this code in the types/index.d.ts file at line 2668 causes this:
/** * @param A A single matrix * @param dimension The mean over the selected dimension * @returns The mean value */mean<TextendsMathScalarType>(A: T[]|T[][],dimension?: number|BigNumber): T
This has a return value of T, but it actually returns T[] when you have dimension=1 and we want the annotated type to match.
should create an error saying "Type 'MathScalarType' is not assignable to type 'number[]'". But this works perfectly as intended and does actually return the answer correctly.
This happens on mean, min, max, std, and maybe more things that involve axis but I haven't tested them.
The text was updated successfully, but these errors were encountered:
To solve this issue, we need to go through all statistical functions like mean that have an optional property dimension, and change the type definition such that it matches the actual behavior. When dimension is provided, the returned type will not be a scalar but a matrix/array (just try it out to see what happens :) ).
Describe the bug
On functions like mean, min, max, std, if you take some 2d number array and want to aggregate it along the 1 axis to retrieve a 1d array of output, you want to get some kind of array/matrix/vector type back. However, it only returns MathScalarType which causes a typescript error. I believe that this code in the types/index.d.ts file at line 2668 causes this:
This has a return value of
T
, but it actually returnsT[]
when you have dimension=1 and we want the annotated type to match.To Reproduce
something like
should create an error saying "Type 'MathScalarType' is not assignable to type 'number[]'". But this works perfectly as intended and does actually return the answer correctly.
This happens on mean, min, max, std, and maybe more things that involve axis but I haven't tested them.
The text was updated successfully, but these errors were encountered: