Add row and column functions for SparseMatrix#1413
Conversation
|
Hi @SzechuanSage thanks for implementing these functions :) What advantage do they give over http://mathjs.org/docs/reference/classes/sparsematrix.html#SparseMatrix+subset? |
|
I think we can safely ignore the fact that codecov is giving this pull request a red cross |
|
The change was a request in issue 1144
Jos suggested using the parser but the OP did not want to use it to save
space in the code. I'll look into using subset.
Cheers
…On Wed, Feb 20, 2019 at 9:17 PM Harry Sarson ***@***.***> wrote:
Hi @SzechuanSage <https://github.com/SzechuanSage> thanks for
implementing these functions :)
What advantage do they give over
http://mathjs.org/docs/reference/classes/sparsematrix.html#SparseMatrix+subset
?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1413 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADKmy4JwEhVM8fzU2JQIgMkZ68qS10gbks5vPS7dgaJpZM4bE4jJ>
.
|
|
Refs: #1144 :) |
|
I had a look at subset(). It requires the use of an Index object (and possibly a Range object). Maybe this would be acceptable for the poster of #1144. In any case, the row() and column() functions take a single parameter (a number) and they are quite short and self-contained. |
These are two utility functions, which make it easy to do something that is very easy in the expression parser ( |
|
@SzechuanSage your PR looks very neat, thanks! Some feedback:
|
|
@SzechuanSage and @harrysarson one more thought: currently mathjs uses functions wherever possible, maybe we should also implement |
|
Could we have both - a function and a method? How is |
|
So if row was a function, it would take a Matrix as the first parameter and a row index as the second parameter? What advantage does this have over keeping row as a Matrix method? |
I'm having two reasons in mind why this may make sense:
I was thinking the other way around: |
|
As for offering both a method and a function: we have that right now in some cases, like with |
|
@josdejong this is your call. I am happy to add this functionality to \src\function\matrix. And if you like, remove it from \src\type\matrix. The unit tests can be replicated (or moved if row and column will not be methods any more). And I am happy to updated the documentation too. |
|
Thanks @SzechuanSage, yes I prefer having functions instead of methods 👍 |
|
Thanks for your updates @SzechuanSage , looks really good. Thanks for taking care of unit tests and docs too! Two things are left I think:
|
|
The only thing I would like confirmed is whether or not I have done the correct thing in the transform functions. Please let me know if any further changes are required. |
|
Thanks @SzechuanSage! I will check it out coming weekend. |
|
The transforms look good @SzechuanSage 👍 Two more things:
|
|
Certainly. I'll get onto that in the next few days. Thank-you for letting
me know.
…On Mon, Mar 18, 2019 at 3:18 AM Jos de Jong ***@***.***> wrote:
The transforms look good @SzechuanSage <https://github.com/SzechuanSage>
👍
Two more things:
1. In both row.test.js and column.test.js, it turns out most of the
tests are not actually executed: a nested it(...) inside another
it(...) is not executed by mocha it seems. Can you flatten the tests?
(I figured this out thanks to the coverage tests
<https://codecov.io/gh/josdejong/mathjs/compare/0647fc1b875cc09d12c68c5c214342aae550a624...aea52eca4595731093cd4ed5464ca26f88d3bc33/diff>
which claim that the actual logic in _row and _column is never
executed.)
2. Can you write a unit test using both row and column in the
expression parser (file parse.test.js), then we know for sure whether
the transforms indeed work with one based indices.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1413 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADKmy-qn8g_sUXXrOUIUutyX45xRmkswks5vXnjTgaJpZM4bE4jJ>
.
|
|
Nice job Chris, thanks again 👍 I've merged the new functions, expect to do a release coming weekend. |
|
I am happy I was able to help. Doing this taught me much. |
|
The new functions @SzechuanSage sorry for the huge delay, I mistakenly thought the functions where already released. |
No description provided.