Skip to content

Conversation

@Anadian
Copy link

@Anadian Anadian commented Dec 28, 2025

A very, very simple pull request just correcting a mistake in the documentation comment in src/function/relational/equal.js (d6cc866).

The file had previously claimed that

   *
   *    const a = math.unit('50 cm')
   *    const b = math.unit('5 m')
   *    math.equal(a, b)             // returns true
   *

which, in addition to not being true in a real sense, I can confirm via REPL that it's not true to mathjs either:

> MathJS.equal( MathJS.unit( '5 m' ), MathJS.unit( '50 cm' ) );
false

so I've now changed the comment to

   *
   *    const a = math.unit('50 cm')
   *    const b = math.unit('5 m')
   *    math.equal(a, b)             // returns false
   *
   *    const a = math.unit('500 cm')
   *    const b = math.unit('5 m')
   *    math.equal(a, b)             // returns true
   *

The second commit (45bdaf9) is just a bit of housekeeping; adding pnpm-lock.yaml to .gitignore. I don't think this should be an issue for anyone, but if it breaks something I'm unaware of, feel free to ignore it.

@gwhitney
Copy link
Collaborator

gwhitney commented Jan 3, 2026

@Anadian , thank you so much for your interest in mathjs and for taking the time to prepare a PR to improve the mistaken example in equal.js.

The mathjs package actually has a test to verify that all of the examples in the documentation of all of the functions are correct -- except, when that facility was put in place, there were so many errors that in order to institute it, it was necessary to create an "exception list" of functions that did have errors in their documentation examples. The idea of this was that over time, as the functions were worked on, we would get all of the examples working correctly and remove functions from the exception list bit by bit until they were all gone.

So this exception list is the variable knownProblems in the file test/node-tests/doc.test.js. Since you are addressing a problem with a documentation example, in this PR we need to remove equal from the knownProblems array. Then you can run npm run build-and-test and it will make sure that all of the examples in the equal documentation run correctly. Please update this PR accordingly.

Adding pnpm-lock.yaml to the .gitignore has nothing to do with this change. I am not necessarily against that, but you would need to put it in a separate PR. So please remove that change from this PR. I would recommend proposing the change to .gitignore in an issue before filing a PR, so that Jos can decide on it. As this project is managed by npm and not pnpm, I can't predict what his reaction will be to mentioning pnpm-lock.yaml in this repo's .gitignore.

Finally, at the moment we are in process of adding per-function HISTORY to each function as it is worked on. Because this is a new initiative and there are not so many examples, I am willing to do this if everything else is ready, but I thought I would mention it if you wanted to take a crack at adding the HISTORY for equal yourself. You can see one example for the function parse at src/expression/parse.js. Just let me know if you plan to try to do this yourself or if you would prefer I add the History section to equal.js before merging the PR, once it is otherwise ready.

Thanks and looking forward to getting this merged.

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

Successfully merging this pull request may close these issues.

2 participants