Skip to content

Commit d2d4e5a

Browse files
committed
add back test_divide_python_scalar
this test keeps test coverage of some branches related to type resolution
1 parent 2976e95 commit d2d4e5a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

dpctl/tests/elementwise/test_divide.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
import ctypes
18+
1719
import numpy as np
1820
import pytest
1921

@@ -60,6 +62,27 @@ def test_divide_dtype_matrix(op1_dtype, op2_dtype):
6062
assert (dpt.asnumpy(r) == expected.astype(r.dtype)).all()
6163

6264

65+
@pytest.mark.parametrize("arr_dt", _all_dtypes)
66+
def test_divide_python_scalar(arr_dt):
67+
q = get_queue_or_skip()
68+
skip_if_dtype_not_supported(arr_dt, q)
69+
70+
X = dpt.ones((10, 10), dtype=arr_dt, sycl_queue=q)
71+
py_ones = (
72+
bool(1),
73+
int(1),
74+
float(1),
75+
complex(1),
76+
np.float32(1),
77+
ctypes.c_int(1),
78+
)
79+
for sc in py_ones:
80+
R = dpt.divide(X, sc)
81+
assert isinstance(R, dpt.usm_ndarray)
82+
R = dpt.divide(sc, X)
83+
assert isinstance(R, dpt.usm_ndarray)
84+
85+
6386
@pytest.mark.parametrize("op1_dtype", _all_dtypes)
6487
@pytest.mark.parametrize("op2_dtype", _all_dtypes)
6588
def test_divide_inplace_dtype_matrix(op1_dtype, op2_dtype):

0 commit comments

Comments
 (0)