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 (data-type, optional) -- The data type of the array. For binary input data, the data must be in exactly this format. Default is the default floating point data type for the device where the returned array is allocated.

  • 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.

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

  • device ({None, string, SyclDevice, SyclQueue}, optional) -- An array API concept of device where the output array is created. The device can be None (the default), an OneAPI filter selector string, an instance of dpctl.SyclDevice corresponding to a non-partitioned SYCL device, an instance of dpctl.SyclQueue, or a Device object returned by dpnp.dpnp_array.dpnp_array.device property.

  • usm_type ({None, "device", "shared", "host"}, optional) -- The type of SYCL USM allocation for the output array. Default is "device".

  • sycl_queue ({None, SyclQueue}, optional) -- A SYCL queue to use for output array allocation and copying.

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])