Skip to content

Commit

Permalink
[x64] jnp.packbits: avoid implicit promotion of boolean inputs
Browse files Browse the repository at this point in the history
Why? Under the new strict promotion flag, booleans promotion to integer will error.
This change makes it so that jnp.packbits still works with strict promotion enabled.
  • Loading branch information
jakevdp committed May 31, 2022
1 parent 29af527 commit 111f006
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jax/_src/numpy/lax_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3314,7 +3314,7 @@ def packbits(a, axis: Optional[int] = None, bitorder='big'):
raise TypeError('Expected an input array of integer or boolean data type')
if bitorder not in ['little', 'big']:
raise ValueError("'order' must be either 'little' or 'big'")
a = greater(a, 0).astype('uint8')
a = lax.gt(a, _lax_const(a, 0)).astype('uint8')
bits = arange(8, dtype='uint8')
if bitorder == 'big':
bits = bits[::-1]
Expand Down

0 comments on commit 111f006

Please sign in to comment.