dpnp.fromstring

dpnp.fromstring(string, dtype=<class 'float'>, count=-1, *, sep, like=None, device=None, usm_type='device', sycl_queue=None)[source]

A new 1-D array initialized from text data in a string.

For full documentation refer to numpy.fromstring.

Parameters:
  • string (str) -- A string containing the data.

  • dtype ({None, str, dtype object}, optional) --

    The data type of the array. For binary input data, the data must be in exactly this format. If None, uses a default floating point data type for the device on which the returned array is allocated.

    Default: float.

  • count (int, optional) --

    Read this number of dtype elements from the data. If this is negative (the default), the count will be determined from the length of the data.

    Default: -1.

  • sep (str) -- The string separating numbers in the data; extra whitespace between elements is also ignored.

  • 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 of dpctl.SyclDevice corresponding to a non-partitioned SYCL device, an instance of dpctl.SyclQueue, or a dpnp.tensor.Device object returned by dpnp.ndarray.device.

    Default: None.

  • usm_type ({None, "device", "shared", "host"}, optional) --

    The type of SYCL USM allocation for the output array.

    Default: "device".

  • 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 -- The constructed array.

Return type:

dpnp.ndarray

Limitations

Parameter like is supported only with default value None. Otherwise, the function raises NotImplementedError exception.

Notes

This uses numpy.fromstring and coerces the result to a DPNP array.

See also

dpnp.frombuffer

Construct array from the buffer data.

dpnp.fromfile

Construct array from data in a text or binary file.

dpnp.fromiter

Construct array from an iterable object.

Examples

>>> import dpnp as np
>>> np.fromstring('1 2', dtype=int, sep=' ')
array([1, 2])
>>> np.fromstring('1, 2', dtype=int, sep=',')
array([1, 2])