Skip to content
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

Ufunc support #25

Merged
merged 5 commits into from
Oct 11, 2022
Merged

Ufunc support #25

merged 5 commits into from
Oct 11, 2022

Conversation

nstarman
Copy link
Owner

@nstarman nstarman commented Sep 28, 2022

Description

Add support for overloading ufuncs and their methods (like accumulate).

Fixes #19, #23

PR Checklist

  • Check out the contributing guidelines and code of conduct
  • Check out the contributing workflow ( for a practical example click here )
  • Give a detailed description of the PR above.
  • Document changes in the CHANGES.rst file. See existing changelog for examples.
  • Add tests, if applicable, to ensure code coverage never decreases.
  • Make sure the docs are up to date, if applicable, particularly the docstrings and RST files in docs folder.
  • Ensure linear history by rebasing, when requested by the maintainer.

@nstarman nstarman added this to the v0.1 milestone Sep 28, 2022
@codecov
Copy link

codecov bot commented Sep 28, 2022

Codecov Report

Base: 93.67% // Head: 87.39% // Decreases project coverage by -6.27% ⚠️

Coverage data is based on head (3eba2c4) compared to base (8838c78).
Patch coverage: 87.16% of modified lines in pull request are covered.

❗ Current head 3eba2c4 differs from pull request most recent head e1ae3ab. Consider uploading reports for the commit e1ae3ab to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
- Coverage   93.67%   87.39%   -6.28%     
==========================================
  Files           7       11       +4     
  Lines         237      468     +231     
==========================================
+ Hits          222      409     +187     
- Misses         15       59      +44     
Impacted Files Coverage Δ
src/overload_numpy/_typeutils.py 65.00% <65.00%> (ø)
src/overload_numpy/constraints.py 97.50% <66.66%> (-2.50%) ⬇️
src/overload_numpy/overload.py 70.42% <68.42%> (-18.59%) ⬇️
src/overload_numpy/mixin.py 72.72% <76.47%> (-8.23%) ⬇️
src/overload_numpy/wrapper/dispatch.py 90.00% <90.00%> (ø)
src/overload_numpy/wrapper/func.py 92.92% <92.92%> (ø)
src/overload_numpy/wrapper/ufunc.py 93.82% <93.82%> (ø)
src/overload_numpy/wrapper/many.py 95.83% <95.83%> (ø)
src/overload_numpy/utils.py 96.55% <96.55%> (ø)
src/overload_numpy/__init__.py 100.00% <100.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@nstarman
Copy link
Owner Author

nstarman commented Sep 28, 2022

@mhvk, obviously still a work in progress, but I've solved the ufunc overloads. And it still compiles with mypyc for super duper speed (🤞🏼, benchmarks upcoming). https://overload-numpy--25.org.readthedocs.build/en/25/

@mhvk
Copy link

mhvk commented Sep 28, 2022

@nstarman - in principle sounds interesting but sadly having limited time to actually look at this -- probably better to meet in person at some point.

But obviously, if this makes things like adding two quantities quite a lot faster, that would be great! I'm not sure that for Quantity, __array_ufunc__ itself is the main bottleneck, but the unit handling stuff can perhaps be compiled too? Anyway, would indeed be good to benchmark...

@nstarman nstarman mentioned this pull request Sep 29, 2022
3 tasks
@nstarman nstarman linked an issue Oct 6, 2022 that may be closed by this pull request
3 tasks
@github-actions github-actions bot added the GitHub label Oct 8, 2022
@nstarman nstarman force-pushed the ufunc branch 15 times, most recently from a1c22e2 to b0f774e Compare October 10, 2022 05:05
Signed-off-by: nstarman <nstarkman@protonmail.com>
Signed-off-by: nstarman <nstarkman@protonmail.com>
Signed-off-by: nstarman <nstarkman@protonmail.com>
Signed-off-by: nstarman <nstarkman@protonmail.com>
@nstarman nstarman marked this pull request as ready for review October 11, 2022 00:06
Signed-off-by: nstarman <nstarkman@protonmail.com>
@nstarman
Copy link
Owner Author

Codecov is erroneously counting TYPE_CHECKING and ... lines against the code coverage. When I run this locally, the coverage is 92%, which is expected. I'll fix the codecov error in a later PR.

@nstarman nstarman merged commit be8bb29 into main Oct 11, 2022
@nstarman nstarman deleted the ufunc branch October 11, 2022 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add __numpy_ufunc__ overrides Change to NotImplemented
2 participants