Skip to content

Commit 46ea738

Browse files
Add support bool fp
1 parent b85234f commit 46ea738

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

dpnp/dpnp_iface_mathematical.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,9 +2891,13 @@ def interp(x, xp, fp, left=None, right=None, period=None):
28912891
x = dpnp.astype(x, x_float_type, order="C", casting="safe", copy=False)
28922892
xp = dpnp.astype(xp, x_float_type, order="C", casting="safe", copy=False)
28932893

2894-
out_dtype = dpnp.common_type(x, xp, fp)
2894+
if fp.dtype == dpnp.bool:
2895+
# Handle bool type for `fp` to follow NumPy behavior
2896+
out_dtype = x_float_type
2897+
else:
2898+
out_dtype = dpnp.common_type(x, xp, fp)
28952899

2896-
fp = dpnp.asarray(fp, dtype=out_dtype, order="C")
2900+
fp = dpnp.astype(fp, out_dtype, order="C", casting="safe", copy=False)
28972901

28982902
if period is not None:
28992903
if not dpnp.isscalar(period):

dpnp/tests/test_mathematical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ class TestInterp:
11501150
@pytest.mark.parametrize(
11511151
"dtype_xp", get_all_dtypes(no_complex=True, no_none=True)
11521152
)
1153-
@pytest.mark.parametrize("dtype_y", get_all_dtypes(no_bool=True))
1153+
@pytest.mark.parametrize("dtype_y", get_all_dtypes())
11541154
def test_all_dtypes(self, dtype_x, dtype_xp, dtype_y):
11551155
x = numpy.linspace(0.1, 9.9, 20).astype(dtype_x)
11561156
xp = numpy.linspace(0.0, 10.0, 5).astype(dtype_xp)
@@ -1182,7 +1182,7 @@ def test_complex_fp(self, dtype_x, dtype_y):
11821182
assert_dtype_allclose(result, expected)
11831183

11841184
@pytest.mark.parametrize(
1185-
"dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True)
1185+
"dtype", get_all_dtypes(no_complex=True, no_none=True)
11861186
)
11871187
def test_left_right_args(self, dtype):
11881188
x = numpy.array([-1, 0, 1, 2, 3, 4, 5, 6], dtype=dtype)

0 commit comments

Comments
 (0)