Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor issues in doc examples #2902

Closed
tmtron opened this issue Feb 21, 2023 · 2 comments
Closed

minor issues in doc examples #2902

tmtron opened this issue Feb 21, 2023 · 2 comments

Comments

@tmtron
Copy link
Contributor

tmtron commented Feb 21, 2023

Here are some minor issues in the doc examples, that I have found.

quantileSeq

quantileSeq([3, -1, 5, 7], [1/3, 2/3])
TypeError: Unexpected type of argument in function quantileSeq

It seems the 2nd argument must not be an array. But accordig to the docs it should work.

to

to(unit('2 inch'), unit(null, 'cm')) # returns Unit 5.08 cm
TypeError: Unexpected type of argument in function unit (expected: number or BigNumber or Fraction or Unit or string or Array or Matrix or Complex or boolean, actual: identifier | null, index: 0)

unit(null, 'cm') is strange. What should this do?

distance

in the final line of the examples the closing ) is missing

distance(  {pointX: 2, pointY: 3, pointZ: 1},  {x0: 1, y0: 1, z0: 2, a: 5, b: 0, c: 1}
SyntaxError: Parenthesis ) expected (char 87)

getMatrixDataType

fractionX = [ [fraction(1, 3)], [fraction(1, 3] ]
SyntaxError: Parenthesis ) expected (char 47)

closing ) of last fraction() missing. This is correct:

fractionX = [ [fraction(1, 3)], [fraction(1, 3)] ]
#                                             ^correct

max

max([[2, 5], [4, 3]], [1, 7], 1) 
#                  ^ wrong
max([[2, 5], [4, 3], [1, 7] ], 1) 
#                           ^correct

subset

  const e: any = [];
  const f = mathJs.subset(e, mathJs.index(0, [0, 2]), [5, 6]);
  /**
   * variable | according to the docs | actual 
   *    e     |          [[5, 0, 6]]  | []
   *    f     |          [[5, 6]]     | [ [ 5, 0, 6 ] ]
   * 
   */

Should e really be changed after calling subset?

@josdejong
Copy link
Owner

Thanks!!

quantileSeq

This actually was a bug: the function quantileSeq did not accept a matrix as second argument, only an array. It would be helpful to rewrite the function as a typed-function, but for now I applied a small fix.

to

If I remember well, unit(null, 'cm') was possible in the past to create a unit without value. Right now you have to do unit('cm') instead. I've fixed the example accordingly.

distance

Fixed

getMatrixDataType

Fixed

max

Fixed

subset

Fixed

@josdejong
Copy link
Owner

The fixes are now published in v11.6.0.

jakubriegel pushed a commit to jakubriegel/mathjs that referenced this issue Mar 1, 2023
josdejong added a commit that referenced this issue Mar 9, 2023
* #2567: accept array as parameter for gcd()

* #2567: accept 1d matrix as gcd() argument

* #2567: support nested 1d array in gcd

* #2567: simplify matrix signature

* [fix] intersect method parameter type (#2897)

* Update history and authors (see #2897)

* feat: added chirp-z transform to calculate non-power-of-2 fft (#2900)

* added chirp-z transform to calculate non-power-of-2 fft

* simplify/remove _ifft function inside _czt function

* chore: remove an unused dependency from `simplifyConstant`

* fix: quantileSeq not accepting a matrix as second argument `prob` (see #2902)

* fix a broken example of function `to`

* fix a typo in the examples functions `distance`, `getMatrixDataType`, `subset`, and `max` (see #2902)

* fix linting issue

* Broadcasting (#2895)

* broadcasting

* Simplified broadcasting

* Updated for broadcasting

* Changed to camel case

* Camel case and auto formating

* Added comments

* Skip if matrices have the same size

* Fixed issue with undefined variable

missing dot  in `A._size`

* Implemented broadcasting in all functions

* Added helper functions

* Added function to check for broadcasting rules

* Tests for broadcasted arithmetic

* Fixed issue with matrix the size of a vector

* Documented and updated broadcasting

* Included broadcast.test

---------

Co-authored-by: David Contreras <david.contreras@guentner.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>

* Update history and authors

* Update devDependencies

* publish v11.6.0

* fix #2906: improve description of the behavior of `subset` for scalar values in the docs

* fix #2907: determinant of empty matrix should be 1

* chore: add a few more unit tests to `det`

---------

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Co-authored-by: Jaeu Jeong <wodndb@gmail.com>
Co-authored-by: cyavictor88 <100557319+cyavictor88@users.noreply.github.com>
Co-authored-by: David Contreras <dvd.cnt@gmail.com>
Co-authored-by: David Contreras <david.contreras@guentner.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants