-
Notifications
You must be signed in to change notification settings - Fork 61
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
Fast exponentiation for tensor product #809
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #809 +/- ##
======================================
Coverage 97.8% 97.8%
======================================
Files 168 168
Lines 3259 3263 +4
Branches 800 800
======================================
+ Hits 3189 3193 +4
Misses 46 46
Partials 24 24 ☔ View full report in Codecov by Sentry. |
Nice. Thanks for those changes, @tnemoz ! That looks good to me, but I'll also defer to @purva-thakre for any additional comments that she may have. Thanks for your quick turn around, @tnemoz --great work as always! |
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.
LGTM too!
I just have one suggested change for something you were not responsible for. Would it be possible to change *args
in the user input field? In the docstring, we state that we allow 3 different types of inputs. Mentioning those types using |
would make it easier to read the API.
You will also have to make changes to :param args:
.
I'm unsure about how that would go to be fair. From what I now, if def tensor(*args: np.ndarray) -> np.ndarray: doesn't work since the possibility of passing an def tensor(*args: np.ndarray | int | list[np.ndarray]) -> np.ndarray: but it somehows also indicates that something like All in all, I'm not sure adding type hinting here would be beneficial, as it could indicate that several cases which should be valid, actually aren't. That being said, I'm no expert in the topic. If you want to add the type hinting here, what is the approach that I should consider here? |
So, this is a personal preference where I would rather user Reading the docstring entry for def tensor(input_mat: list[np.ndarray]| np.ndarray, int| np.ndarray, ... , np.ndarray) -> np.ndarray: Maybe you have to sandwich the last two allowed inputs in We have a couple of functions like this and of course, I can't remember which ones right now to link them here. lol. |
Hi @tnemoz, for future scenarios, please make sure you create a branch from the master of your fork before you start working on a PR. This makes it easier for us to make changes to a PR branch, if needed. I tried to check out this branch locally but I don't have permission to push changes into this. |
Going to go ahead and merge this. The remaining discussion could be resolved as part of #299 |
Hey @purva-thakre! Sorry for that :( Something along the lines of "since my master branch is protected, you can't push on it"? Or not at all? Just to be sure I don't repeat the same mistake! |
Description
Implements the fact exponentiation algorithm to compute the tensor powers of a matrix. Fixes #803.
Changes
Checklist
Before marking your PR ready for review, make sure you checked the following locally. If this is your first PR, you might be notified of some workflow failures after a maintainer has approved the workflow jobs to be run on your PR.
Additional information is available in the documentation.
ruff
for errors related to code style and formatting.pytest
.Sphinx
build can be checked locally for any failures related to your PRlinkcheck
to check for broken links in the documentationdoctest
to verify the examples in the function docstrings work as expected.