dpnp.require
- dpnp.require(a, dtype=None, requirements=None, *, like=None)[source]
Return a
dpnp.ndarrayof the provided type that satisfies requirements.This function is useful to be sure that an array with the correct flags is returned for passing to compiled code (perhaps through ctypes).
For full documentation refer to
numpy.require.- Parameters:
a ({dpnp.ndarray, usm_ndarray}) -- The input array to be converted to a type-and-requirement-satisfying array.
dtype ({None, str, dtype object}, optional) --
The required data-type. If
Nonepreserve the current dtype.Default:
None.requirements ({None, str, sequence of str}, optional) --
The requirements list can be any of the following:
'F_CONTIGUOUS' ('F') - ensure a Fortran-contiguous array
'C_CONTIGUOUS' ('C') - ensure a C-contiguous array
'WRITABLE' ('W') - ensure a writable array
Default:
None.
- Returns:
out -- Array with specified requirements and type if given.
- Return type:
dpnp.ndarray
Limitations
Parameter like is supported only with default value
None. Otherwise, the function raises NotImplementedError exception.See also
dpnp.asarrayConvert input to an ndarray.
dpnp.asanyarrayConvert to an ndarray, but pass through ndarray subclasses.
dpnp.ascontiguousarrayConvert input to a contiguous array.
dpnp.asfortranarrayConvert input to an ndarray with column-major memory order.
dpnp.ndarray.flagsInformation about the memory layout of the array.
Notes
The returned array will be guaranteed to have the listed requirements by making a copy if needed.
Examples
>>> import dpnp as np >>> x = np.arange(6).reshape(2, 3) >>> x.flags C_CONTIGUOUS : True F_CONTIGUOUS : False WRITEABLE : True
>>> y = np.require(x, dtype=np.float32, requirements=['W', 'F']) >>> y.flags C_CONTIGUOUS : False F_CONTIGUOUS : True WRITEABLE : True