-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat: add Symmetric and Distance Matrix #178
Conversation
I didn't found a formula to compute compact index from row/column coordinate
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #178 +/- ##
==========================================
+ Coverage 71.27% 73.53% +2.26%
==========================================
Files 34 36 +2
Lines 5295 5733 +438
Branches 850 937 +87
==========================================
+ Hits 3774 4216 +442
+ Misses 1516 1512 -4
Partials 5 5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looked at the API and terminology used, not the implementation.
LGTM, I just have one issue. Is "side" a common / standard way to refer to the both row / column in a symmetric matrix? I'm wondering if we could find a better term.
My suggestion would be to:
- rename
sideSize
=>diagonalSize
(getter and param names). The term "diagonal" is more specific to square / symmetric matrices than "side". - remove
addSide
andremoveSide
(we already haveaddRow
,addColumn
etc.)
Thx for your return, I was struggled by "side" but found nothing better. diagonalSize seems better. I do not agree on removing What do you think for |
Can you move the new classes to separate files? |
|
implementation with Matrix composition
implementation with Matrix composition
SymmetricMatrix implement AbstractMatrix using composition pattern with Matrix. DistanceMatrix keep extends SymmetricMatrix
from @targos feedbacks: refactor to extends from AbstractMatrix done, (use matrix composition for implementation). move to addCross / removeCross done. I will cut matrix.js file. |
0bb2ff4
to
bf05f94
Compare
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM.
I'm just confused with the upperRightValues/upperRightEntries
API. What's the use case, especially for iterating outside of the matrix dimensions?
Yeah, maybe theses iterators should be only on Symmetric/Distance Matrix |
What's the problem with iterating on a non-equilateral triangle? |
Ambiguity and so, your confusion, I have no real use case in mind about iterating like that upon a non-square matrix. Maybe, upperRightValues should not assume a square algorithm instead, like that, no werid API like maxBorder and missValue. |
OK, maybe we only allow to call this method on a square matrix. |
It has no real usage on non-symmetric matrix
Sometime I hate Typescript, because AbstractMatrix factories return Matrix, I can't override them in my SymmetricMatrix because SymmetricMatrix is not a Matrix but an AbstractMatrix. I think the proper way is theses static factories return type is AbstractMatrix, but it's a breaking change. and it will force casting when we would use specific Matrix method from factories |
Can't we somehow ask for the method to return "this" i.e. the current constructor. |
Seems no |
I suggest we just remove the definitions from the AbstractMatrix class then. |
Or make it generic with a default to |
static zeros<M extends AbstractMatrix = Matrix>(
rows: number,
columns: number,
): M; Allow me to not have error on inheritance but I must extends like that static zeros<M extends AbstractMatrix = SymmetricMatrix>(
diagonalSize: number,
): M; I can't restrict the extends, so type can be set to Matrix but it will not return a Matrix 😬.
|
What bother me the most is the error is on class, not on method. so I cannot |
Let's make it return |
I'll keep like that, I specified in doc to not specify the generic. But we can create an issue for review factory functions and move them into Matrix instead AbstractMatrix. |
48164c2
to
534c30b
Compare
No description provided.