dpnp.asarray_chkfinite
- dpnp.asarray_chkfinite(a, dtype=None, order=None, *, device=None, usm_type=None, sycl_queue=None)[source]
Convert the input to an array, checking for NaNs or Infs.
For full documentation refer to
numpy.asarray_chkfinite.- Parameters:
arr (array_like) -- Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays. Success requires no NaNs or Infs.
dtype ({None, str, dtype object}, optional) --
By default, the data-type is inferred from the input data.
Default:
None.order ({None, "C", "F", "A", "K"}, optional) --
Memory layout of the newly output array.
Default:
"K".device ({None, string, SyclDevice, SyclQueue, Device}, optional) --
An array API concept of device where the output array is created. device can be
None, a oneAPI filter selector string, an instance ofdpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, or adpctl.tensor.Deviceobject returned bydpnp.ndarray.device.Default:
None.usm_type ({None, "device", "shared", "host"}, optional) --
The type of SYCL USM allocation for the output array.
Default:
None.sycl_queue ({None, SyclQueue}, optional) --
A SYCL queue to use for output array allocation and copying. The sycl_queue can be passed as
None(the default), which means to get the SYCL queue from device keyword if present or to use a default queue.Default:
None.
- Returns:
out -- Array interpretation of a. No copy is performed if the input is already an ndarray.
- Return type:
dpnp.ndarray
- Raises:
ValueError -- Raises
ValueErrorif a contains NaN (Not a Number) or Inf (Infinity).
See also
dpnp.asarrayCreate an array.
dpnp.asanyarrayConverts an input object into array.
dpnp.ascontiguousarrayConvert input to a c-contiguous array.
dpnp.asfortranarrayConvert input to an array with column-major memory order.
dpnp.fromiterCreate an array from an iterator.
dpnp.fromfunctionConstruct an array by executing a function on grid positions.
Examples
>>> import dpnp as np
Convert a list into an array. If all elements are finite,
asarray_chkfiniteis identical toasarray.>>> a = [1, 2] >>> np.asarray_chkfinite(a, dtype=np.float32) array([1., 2.])
Raises
ValueErrorif array_like contains NaNs or Infs.>>> a = [1, 2, np.inf] >>> try: ... np.asarray_chkfinite(a) ... except ValueError: ... print('ValueError') ValueError
Creating an array on a different device or with a specified usm_type
>>> x = np.asarray_chkfinite([1, 2, 3]) # default case >>> x, x.device, x.usm_type (array([1, 2, 3]), Device(level_zero:gpu:0), 'device')
>>> y = np.asarray_chkfinite([1, 2, 3], device="cpu") >>> y, y.device, y.usm_type (array([1, 2, 3]), Device(opencl:cpu:0), 'device')
>>> z = np.asarray_chkfinite([1, 2, 3], usm_type="host") >>> z, z.device, z.usm_type (array([1, 2, 3]), Device(level_zero:gpu:0), 'host')