Skip to content

Commit cfb968d

Browse files
author
jax authors
committed
Merge pull request #20258 from Gattocrucco:digitize-fix-corner-case
PiperOrigin-RevId: 616995961
2 parents d8f231a + fb91b51 commit cfb968d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

jax/_src/numpy/lax_numpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5373,7 +5373,7 @@ def digitize(x: ArrayLike, bins: ArrayLike, right: bool = False) -> Array:
53735373
if bins_arr.ndim != 1:
53745374
raise ValueError(f"digitize: bins must be a 1-dimensional array; got {bins=}")
53755375
if bins_arr.shape[0] == 0:
5376-
return zeros(x, dtype=dtypes.canonicalize_dtype(int_))
5376+
return zeros_like(x, dtype=int32)
53775377
side = 'right' if not right else 'left'
53785378
return where(
53795379
bins_arr[-1] >= bins_arr[0],

tests/lax_numpy_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2597,7 +2597,7 @@ def testSearchsortedNans(self, dtype, side, method):
25972597

25982598
@jtu.sample_product(
25992599
xshape=[(20,), (5, 4)],
2600-
binshape=[(1,), (5,)],
2600+
binshape=[(0,), (1,), (5,)],
26012601
right=[True, False],
26022602
reverse=[True, False],
26032603
dtype=default_dtypes,

0 commit comments

Comments
 (0)