spectrochempy.fromiter
- fromiter(iterable, dtype=np.float64, count=-1, **kwargs)[source]
Create a new 1-dimensional array from an iterable object.
- Parameters:
iterable (iterable object) – An iterable object providing data for the array.
dtype (data-type) – The data-type of the returned array.
count (
int
, optional) – The number of items to read from iterable. The default is -1, which means all data is read.**kwargs – Other kwargs are passed to the final object constructor.
- Returns:
fromiter – The output nddataset.
See also
fromfunction
Construct a nddataset by executing a function over each coordinate.
Notes
- Specify count to improve performance. It allows fromiter to pre-allocate the
output array, instead of resizing it on demand.
Examples
>>> iterable = (x * x for x in range(5)) >>> d = scp.fromiter(iterable, float, units='km') >>> d NDDataset: [float64] km (size: 5) >>> d.data array([ 0, 1, 4, 9, 16])