Skip to content

Commit

Permalink
fix: isinf (#23)
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <[email protected]>
  • Loading branch information
nstarman authored Mar 6, 2024
1 parent f85aa11 commit 6d4beb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ jobs:

- name: Test package
run: >-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
--durations=20
python -m pytest tests/ src/ docs/ -ra --cov --cov-report=xml
--cov-report=term --durations=20
- name: Upload coverage report
uses: codecov/[email protected]
7 changes: 6 additions & 1 deletion src/array_api_jax_compat/_elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ def isfinite(x: ArrayLike, /) -> Value:

@quaxify
def isinf(x: ArrayLike, /) -> Value:
return array_api.isinf(x)
# Jax `isinf` makes a numpy array with value `inf` and then compares it with
# the input array. If the input array cannot be compared to base numpy
# arrays, e.g. a Quantity with units, then Jax's `isinf` will raise an
# unwanted error. Instead, we just negate the `isfinite` function, which
# should work for all array-like inputs.
return ~array_api.isfinite(x)


@quaxify
Expand Down

0 comments on commit 6d4beb0

Please sign in to comment.