@@ -235,32 +235,6 @@ def _get_bin_edges(a, bins, range, usm_type):
235235 return bin_edges , None
236236
237237
238- def _normalize_array (a , dtype , usm_type = None ):
239- if usm_type is None :
240- usm_type = a .usm_type
241-
242- try :
243- return dpnp .asarray (
244- a ,
245- dtype = dtype ,
246- usm_type = usm_type ,
247- sycl_queue = a .sycl_queue ,
248- order = "C" ,
249- copy = False ,
250- )
251- except ValueError :
252- pass
253-
254- return dpnp .asarray (
255- a ,
256- dtype = dtype ,
257- usm_type = usm_type ,
258- sycl_queue = a .sycl_queue ,
259- order = "C" ,
260- copy = True ,
261- )
262-
263-
264238def _bincount_validate (x , weights , minlength ):
265239 if x .ndim > 1 :
266240 raise ValueError ("object too deep for desired array" )
@@ -426,16 +400,16 @@ def bincount(x, weights=None, minlength=None):
426400 "supported types"
427401 )
428402
429- x_casted = _normalize_array (x , dtype = x_casted_dtype )
403+ x_casted = dpnp . asarray (x , dtype = x_casted_dtype , order = "C" )
430404
431405 if weights is not None :
432- weights_casted = _normalize_array (weights , dtype = ntype_casted )
406+ weights_casted = dpnp . asarray (weights , dtype = ntype_casted , order = "C" )
433407
434408 n_casted = _bincount_run_native (
435409 x_casted , weights_casted , minlength , ntype_casted , usm_type
436410 )
437411
438- n = _normalize_array (n_casted , dtype = ntype , usm_type = usm_type )
412+ n = dpnp . asarray (n_casted , dtype = ntype , usm_type = usm_type , order = "C" )
439413
440414 return n
441415
@@ -643,10 +617,12 @@ def histogram(a, bins=10, range=None, density=None, weights=None):
643617 "supported types"
644618 )
645619
646- a_casted = _normalize_array (a , a_bin_dtype )
647- bin_edges_casted = _normalize_array (bin_edges , a_bin_dtype )
620+ a_casted = dpnp . asarray (a , dtype = a_bin_dtype , order = "C" )
621+ bin_edges_casted = dpnp . asarray (bin_edges , dtype = a_bin_dtype , order = "C" )
648622 weights_casted = (
649- _normalize_array (weights , hist_dtype ) if weights is not None else None
623+ dpnp .asarray (weights , dtype = hist_dtype , order = "C" )
624+ if weights is not None
625+ else None
650626 )
651627
652628 # histogram implementation uses atomics, but atomics doesn't work with
@@ -681,7 +657,7 @@ def histogram(a, bins=10, range=None, density=None, weights=None):
681657 )
682658 _manager .add_event_pair (mem_ev , ht_ev )
683659
684- n = _normalize_array (n_casted , dtype = ntype , usm_type = usm_type )
660+ n = dpnp . asarray (n_casted , dtype = ntype , usm_type = usm_type , order = "C" )
685661
686662 if density :
687663 db = dpnp .astype (
@@ -1055,9 +1031,11 @@ def histogramdd(sample, bins=10, range=None, weights=None, density=False):
10551031
10561032 _histdd_check_monotonicity (bin_edges_view_list )
10571033
1058- sample_ = _normalize_array (sample , sample_dtype )
1034+ sample_ = dpnp . asarray (sample , dtype = sample_dtype , order = "C" )
10591035 weights_ = (
1060- _normalize_array (weights , hist_dtype ) if weights is not None else None
1036+ dpnp .asarray (weights , dtype = hist_dtype , order = "C" )
1037+ if weights is not None
1038+ else None
10611039 )
10621040 n = _histdd_run_native (
10631041 sample_ ,
@@ -1069,7 +1047,7 @@ def histogramdd(sample, bins=10, range=None, weights=None, density=False):
10691047 )
10701048
10711049 expexted_hist_dtype = _histdd_hist_dtype (queue , weights )
1072- n = _normalize_array (n , expexted_hist_dtype , usm_type )
1050+ n = dpnp . asarray (n , dtype = expexted_hist_dtype , usm_type = usm_type , order = "C" )
10731051
10741052 if density :
10751053 # calculate the probability density function
0 commit comments