Skip to content

Add alias for logical function as called in numpy #462

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

Open
ricardoV94 opened this issue Sep 29, 2023 · 1 comment
Open

Add alias for logical function as called in numpy #462

ricardoV94 opened this issue Sep 29, 2023 · 1 comment

Comments

@ricardoV94
Copy link
Member

Description

  • pt.eq -> pt.equal
  • pt.neq -> pt.not_equal
  • pt._and -> pt.logical_and

And so on: https://numpy.org/doc/stable/reference/routines.logic.html

@lmmx
Copy link
Contributor

lmmx commented Dec 6, 2023

I'm picking this up for the PyData Global sprint, beginning by making a full comparison table (all functions are in pytensor.tensor.math)

NumPy Function PyTensor Equivalent
numpy.all all
numpy.any any
numpy.isfinite
numpy.isinf isinf
numpy.isnan isnan
numpy.isneginf
numpy.isposinf
numpy.iscomplex
numpy.iscomplexobj
numpy.isfortran
numpy.isreal
numpy.isrealobj
numpy.isscalar
numpy.logical_and
numpy.logical_or
numpy.logical_not
numpy.logical_xor
numpy.allclose allclose
numpy.isclose isclose
numpy.array_equal
numpy.array_equiv
numpy.greater gt
numpy.greater_equal ge
numpy.less lt
numpy.less_equal le
numpy.equal eq
numpy.not_equal neq

Of these the direct homonyms are no-ops, so there are only the following 6 to add:

# NumPy logical aliases
greater = gt
greater_equal = ge
less = lt
less_equal = le
equal = eq
not_equal = neq

Edit - on second thought these 4 are wrong:

logical_and = bitwise_and
logical_or = bitwise_or
logical_not = bitwise_not
logical_xor = bitwise_xor

ricardoV94 pushed a commit that referenced this issue Dec 15, 2023
…533)

* feat(numpy logical aliases): add aliases for logical function equivalents in NumPy (#462)

* fix(logical): bitwise and logical are distinct operators

* doc(aliases): Document the new NumPy inequality aliases in the same style as existing bitwise ones.

* refactor(numpy-aliases): collect all NumPy aliases in one block at the end of the file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants