3838"""
3939
4040import operator
41- import warnings
4241
4342import dpctl .utils as dpu
4443import numpy
@@ -104,16 +103,6 @@ def _ravel_check_a_and_weights(a, weights):
104103 dpnp .check_supported_arrays_type (a )
105104 usm_type = a .usm_type
106105
107- # ensure that the array is a "subtractable" dtype
108- if a .dtype == dpnp .bool :
109- warnings .warn (
110- f"Converting input from { a .dtype } to { numpy .uint8 } "
111- "for compatibility." ,
112- RuntimeWarning ,
113- stacklevel = 3 ,
114- )
115- a = dpnp .astype (a , numpy .uint8 )
116-
117106 if weights is not None :
118107 # check that `weights` array has supported type
119108 dpnp .check_supported_arrays_type (weights )
@@ -323,22 +312,26 @@ def bincount(x, weights=None, minlength=None):
323312
324313 Parameters
325314 ----------
326- x : {dpnp.ndarray, usm_ndarray}, 1 dimension, nonnegative ints
327- Input array.
328- weights : {dpnp.ndarray, usm_ndarray}, optional
315+ x : {dpnp.ndarray, usm_ndarray}
316+ Input 1-dimensional array with nonnegative integer values .
317+ weights : {None, dpnp.ndarray, usm_ndarray}, optional
329318 Weights, array of the same shape as `x`.
330- minlength : int, optional
319+ Default: ``None``
320+ minlength : {None, int}, optional
331321 A minimum number of bins for the output array.
322+ Default: ``None``
332323
333324 Returns
334325 -------
335326 out : dpnp.ndarray of ints
336327 The result of binning the input array.
337- The length of `out` is equal to ``np.amax(x)+ 1``.
328+ The length of `out` is equal to ``np.amax(x) + 1``.
338329
339330 See Also
340331 --------
341- dpnp.histogram, dpnp.digitize, dpnp.unique
332+ :obj:`dpnp.histogram` : Compute the histogram of a data set.
333+ :obj:`dpnp.digitize` : Return the indices of the bins to which each value
334+ :obj:`dpnp.unique` : Find the unique elements of an array.
342335
343336 Examples
344337 --------
@@ -349,25 +342,24 @@ def bincount(x, weights=None, minlength=None):
349342 array([1, 3, 1, 1, 0, 0, 0, 1])
350343
351344 >>> x = np.array([0, 1, 1, 3, 2, 1, 7, 23])
352- >>> np.bincount(x).size == np.amax(x)+ 1
353- True
345+ >>> np.bincount(x).size == np.amax(x) + 1
346+ array( True)
354347
355348 The input array needs to be of integer dtype, otherwise a
356349 TypeError is raised:
357350
358- >>> np.bincount(np.arange(5, dtype=float ))
351+ >>> np.bincount(np.arange(5, dtype=np.float32 ))
359352 Traceback (most recent call last):
360353 ...
361- TypeError: Cannot cast array data from dtype('float64') to dtype('int64')
362- according to the rule 'safe'
354+ TypeError: x must be an integer array
363355
364356 A possible use of ``bincount`` is to perform sums over
365- variable-size chunks of an array, using the `` weights` ` keyword.
357+ variable-size chunks of an array, using the `weights` keyword.
366358
367- >>> w = np.array([0.3, 0.5, 0.2, 0.7, 1., -0.6]) # weights
359+ >>> w = np.array([0.3, 0.5, 0.2, 0.7, 1., -0.6], dtype=np.float32 ) # weights
368360 >>> x = np.array([0, 1, 1, 2, 2, 2])
369- >>> np.bincount(x, weights=w)
370- array([ 0.3, 0.7, 1.1])
361+ >>> np.bincount(x, weights=w)
362+ array([0.3, 0.7, 1.1], dtype=float32 )
371363
372364 """
373365
0 commit comments