Skip to content

Commit

Permalink
Merge pull request #19403 from jakevdp:jnp-bool
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 599312340
  • Loading branch information
jax authors committed Jan 17, 2024
2 parents a2040f2 + 71e96fa commit 83ad09c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions jax/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
bincount as bincount,
blackman as blackman,
block as block,
bool_ as bool, # Array API alias for bool_
bool_ as bool_,
broadcast_arrays as broadcast_arrays,
broadcast_shapes as broadcast_shapes,
Expand Down
1 change: 1 addition & 0 deletions jax/numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def bitwise_right_shift(x: ArrayLike, y: ArrayLike, /) -> Array: ...
def bitwise_xor(x: ArrayLike, y: ArrayLike, /) -> Array: ...
def blackman(M: int) -> Array: ...
def block(arrays: Union[ArrayLike, Sequence[ArrayLike], Sequence[Sequence[ArrayLike]]]) -> Array: ...
bool: Any
bool_: Any
def broadcast_arrays(*args: ArrayLike) -> list[Array]: ...

Expand Down
5 changes: 4 additions & 1 deletion tests/lax_numpy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def f():
return f

@parameterized.parameters(
[dtype for dtype in [jnp.bool_, jnp.uint8, jnp.uint16, jnp.uint32,
[dtype for dtype in [jnp.bool, jnp.uint8, jnp.uint16, jnp.uint32,
jnp.uint64, jnp.int8, jnp.int16, jnp.int32, jnp.int64,
jnp.bfloat16, jnp.float16, jnp.float32, jnp.float64,
jnp.complex64, jnp.complex128]
Expand All @@ -191,6 +191,9 @@ def testDtypeWrappers(self, dtype):
prims = [eqn.primitive for eqn in jaxpr.eqns]
self.assertEqual(prims, [lax.convert_element_type_p]) # No copy generated.

def testBoolDtypeAlias(self):
self.assertIs(jnp.bool, jnp.bool_)

@jtu.sample_product(
dtype=float_dtypes + [object],
allow_pickle=[True, False],
Expand Down

0 comments on commit 83ad09c

Please sign in to comment.