Skip to content

Add aliases for arithmetic inequality function equivalents in NumPy #533

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

Merged
merged 5 commits into from
Dec 15, 2023
Merged

Add aliases for arithmetic inequality function equivalents in NumPy #533

merged 5 commits into from
Dec 15, 2023

Conversation

lmmx
Copy link
Contributor

@lmmx lmmx commented Dec 6, 2023

Motivation for these changes

Updated the logical function mappings in PyTensor to align with NumPy's logical functions. This enhances compatibility and eases the transition for users familiar with NumPy, making PyTensor more intuitive and accessible.

Fulfils:

Implementation details

I reviewed the correspondence and made a table in the issue tracker, then made aliases for those that were not a direct name match. I also added them to the __all__ alongside the names they alias.

Checklist

Major / Breaking Changes

  • None, compatibility was added not removed

New features

  • New aliases for tensor logic functions

Bugfixes

  • N/A

Documentation

  • Documented in the style of the existing NumPy aliases

Maintenance

  • N/A

@lmmx
Copy link
Contributor Author

lmmx commented Dec 6, 2023

There are others but they're scattered around the module: perhaps they should all be put together?

bitwise_and = and_  # numpy name for it
bitwise_or = or_  # numpy name for it
bitwise_xor = xor  # numpy name for it
bitwise_not = invert  # numpy alias for it
# alias to sqr, included to maintain similarity with numpy interface
square = sqr
  • None of these are imported into the test file at tests/tensor/test_math.py either 🤔
  • They are covered by docs though here

@lmmx lmmx changed the title feat(numpy logical aliases): add aliases for logical function equivalents in NumPy (#462) feat(numpy inequality aliases): add aliases for arithmetic inequality function equivalents in NumPy (#462) Dec 6, 2023
@lmmx lmmx marked this pull request as ready for review December 6, 2023 19:48
@jessegrabowski
Copy link
Member

I think it would be great to gather everything into one place

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2023

Codecov Report

Merging #533 (e9354b1) into main (c38eea0) will increase coverage by 0.00%.
Report is 2 commits behind head on main.
The diff coverage is 94.43%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #533   +/-   ##
=======================================
  Coverage   80.90%   80.90%           
=======================================
  Files         162      162           
  Lines       46416    46422    +6     
  Branches    11354    11354           
=======================================
+ Hits        37554    37560    +6     
  Misses       6639     6639           
  Partials     2223     2223           
Files Coverage Δ
pytensor/breakpoint.py 55.00% <ø> (ø)
pytensor/compile/builders.py 77.17% <100.00%> (ø)
pytensor/graph/basic.py 89.08% <ø> (ø)
pytensor/graph/rewriting/kanren.py 100.00% <ø> (ø)
pytensor/ifelse.py 51.70% <100.00%> (ø)
pytensor/link/jax/dispatch/random.py 96.05% <100.00%> (ø)
pytensor/link/jax/dispatch/shape.py 87.09% <ø> (ø)
pytensor/link/jax/dispatch/subtensor.py 88.13% <ø> (ø)
pytensor/link/jax/dispatch/tensor_basic.py 91.96% <ø> (ø)
pytensor/link/numba/dispatch/random.py 98.83% <100.00%> (ø)
... and 36 more

@ricardoV94 ricardoV94 changed the title feat(numpy inequality aliases): add aliases for arithmetic inequality function equivalents in NumPy (#462) Add aliases for arithmetic inequality function equivalents in NumPy Dec 10, 2023
@ricardoV94
Copy link
Member

Need to fix conflicts with changes in main, otherwise ready to merge

@lmmx
Copy link
Contributor Author

lmmx commented Dec 14, 2023

On my 3rd try at interactive rebasing I gave up and did it in the web editor! 😮‍💨 It kept saying there were going to be 26 commits, I briefly saw the option to squash but it didn't show up on 2nd try, think that was the right way.

Oh well, should be good now, looks like the web editor didn't mess up the code style check

@ricardoV94 ricardoV94 merged commit 3f960de into pymc-devs:main Dec 15, 2023
@ricardoV94
Copy link
Member

Thanks @lmmx and sorry for the for pain!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants