Skip to content

Commit 1890180

Browse files
committed
Reuse _validate_fill_value from dpctl.tensor._ctors
1 parent 001520e commit 1890180

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

dpnp/dpnp_algo/dpnp_fill.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
# THE POSSIBILITY OF SUCH DAMAGE.
2525
# *****************************************************************************
2626

27-
from numbers import Number
28-
2927
import dpctl.tensor as dpt
3028
import dpctl.utils as dpu
31-
import numpy as np
32-
from dpctl.tensor._ctors import _cast_fill_val
29+
from dpctl.tensor._ctors import _cast_fill_val, _validate_fill_value
3330
from dpctl.tensor._tensor_impl import (
3431
_copy_usm_ndarray_into_usm_ndarray,
3532
_full_usm_ndarray,
@@ -61,10 +58,8 @@ def dpnp_fill(arr, val):
6158
)
6259
_manager.add_event_pair(h_ev, c_ev)
6360
return
64-
elif not isinstance(val, Number) and not isinstance(val, np.bool_):
65-
raise TypeError(
66-
f"Array cannot be filled with `val` of type {type(val)}"
67-
)
61+
else:
62+
_validate_fill_value(val)
6863

6964
dt = arr.dtype
7065
val_type = type(val)

0 commit comments

Comments
 (0)