Replace np.sum(a * b) with a @ b for better performance and accuracy#542
Merged
HumphreyYang merged 7 commits intomainfrom Aug 16, 2025
Merged
Replace np.sum(a * b) with a @ b for better performance and accuracy#542HumphreyYang merged 7 commits intomainfrom
np.sum(a * b) with a @ b for better performance and accuracy#542HumphreyYang merged 7 commits intomainfrom
Conversation
…l, and mccall_model_with_separation Co-authored-by: mmcky <8263752+mmcky@users.noreply.github.com>
Co-authored-by: mmcky <8263752+mmcky@users.noreply.github.com>
Copilot
AI
changed the title
[WIP]
Replace Aug 14, 2025
np.sum(a * b) versus a @ bnp.sum(a * b) with a @ b for better performance and accuracy
mmcky
reviewed
Aug 14, 2025
Member
HumphreyYang
left a comment
There was a problem hiding this comment.
Hi @mmcky,
I had a look over this PR. I think it introduces a bug to lake_model.
Other than that, other changes are correct to me.
Member
|
Hi @mmcky, I incorprated John's comments. I will merge this once it is built. Please let me know if you have further comments or changes you want to make! |
mmcky
approved these changes
Aug 16, 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.
This PR replaces instances of
np.sum(a * b)with the more efficienta @ boperator throughout the lecture series, following best practices for NumPy operations.Changes Made
Educational Enhancement
lectures/linear_algebra.md: Added side-by-side comparison showing both methods:
Explains that
@operator is preferred for performance and numerical accuracy.Direct Replacements
Benefits
Examples
Before:
After:
All changes preserve mathematical equivalence while improving performance through optimized linear algebra operations.
Fixes #463.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.