Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.flatiter

classnumpy.flatiter[source]

Flat iterator object to iterate over arrays.

Aflatiter iterator is returned byx.flat for any arrayx.It allows iterating over the array as if it were a 1-D array,either in a for-loop or by calling itsnext method.

Iteration is done in row-major, C-style order (the lastindex varying the fastest). The iterator can also be indexed usingbasic slicing or advanced indexing.

See also

ndarray.flat
Return a flat iterator over an array.
ndarray.flatten
Returns a flattened copy of an array.

Notes

Aflatiter iterator can not be constructed directly from Python codeby calling theflatiter constructor.

Examples

>>>x=np.arange(6).reshape(2,3)>>>fl=x.flat>>>type(fl)<type 'numpy.flatiter'>>>>foriteminfl:...print(item)...012345
>>>fl[2:4]array([2, 3])

Attributes

coordsAn N-dimensional tuple of current coordinates.

Methods

copy()Get a copy of the iterator as a 1-D array.
next

Previous topic

numpy.ndindex.next

Next topic

numpy.flatiter.coords

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp