Name
flat
Synopsis
a
.flat is an
attribute that contains an array with rank 1 and of the same size as
a, sharing
a’s data. Indexing or
slicing a
.flat lets you
access or change a’s
elements through this alternate view of a.
Trying to access a
.flat
raises a TypeError exception if
a is noncontiguous. When
a is contiguous,
a
.flat is in row-major
order. This means that, for example, when
a’s shape is
(7,4) (i.e., a is a
two-dimensional matrix with seven rows and four columns),
a
.flat[
i
]
is the same as
a
[divmod(
i
,4)]
for all i in range(28).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access