Repository navigation
Closes 4124, align ak.dot to np.dot. - #4224
Merged
Merged
Conversation
drculhane
marked this pull request as ready for review
April 9, 2025 12:05
drculhane
force-pushed
the
Closes-4124
branch
4 times, most recently
from
April 14, 2025 12:29
aa2ca26 to
e982c3e
Compare
e-kayrakli
approved these changes
Apr 14, 2025
e-kayrakli
reviewed
Apr 14, 2025
1RyanK
approved these changes
Apr 15, 2025
ajpotts
added this pull request to the merge queue
Apr 21, 2025
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Apr 21, 2025
ajpotts
added this pull request to the merge queue
Apr 21, 2025
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Apr 21, 2025
ajpotts
added this pull request to the merge queue
Apr 22, 2025
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Apr 22, 2025
ajpotts
added this pull request to the merge queue
Apr 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4124
Summary of work:
There was a lot here, hence these comments so that you won't have to start from scratch when you review this.
Aligning ak.dot to np.dot has been time-consuming, as np.dot does much more than the conventional 1-D vector dot product. Hopefully the comments in def dot, in pdarrayclass.py, make it clear what's going on.
In addition to the executable python code, there's a new docstring that gives examples of all use cases of ak.dot.
It's worth noting that in order to prevent mypy from freaking out, ak.dot requires several # type: ignore statements, as is typical with functions whose inputs accept a Union of types. There's also an unreachable return None (also with a # type: ignore) which prevents mypy from claiming there's a missing return. I considered just having mypy bypass this function.
There were test_dot functions in both pdarrayclass_test.py and numeric_test.py. The one in numeric_test.py has been removed. The one in pdarrayclass_test.py has been changed to cover all the possible use cases and data types of ak.dot.
A possible TODO: move dot out of pdarrayclass.py and into _numeric.py. Similarly with test_dot.
A dotProd function was added to LinalgMsg.chpl to perform the computation (thank you, Ryan). I modified Ryan's code to allow for the case where the two pdarrays aren't of the same type.
In LinalgMsg.chpl, both dotProd and matmul need to compute the return type based on the input types. Both call a function named np_ret_type (which is meant to stand for "numpy return type"). There is a similar function called by vecdot (it's currently called compute_result_type_vecdot). In a future alignment of ak.vecdot to np.vecdot, that function may also be rolled into np_ret_type.
Additional changes were needed in LinalgMsg.chpl, OperatorMsg.chpl and BinOp.chpl to enable all of the appropriate combinations of data types.
Another possible TODO: make a 1D case for dotProd, rather than piggyback onto the ND case.
A very likely TODON'T: make test cases for > 3D. So far, I've found that making arkouda with max_dim > 3 isn't feasible.
Ryan: I'd love if you could add some comments to the dotProd proc in LinalgMsg.chpl.