Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63657857
data_array.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, May 21, 16:15
Size
921 B
Mime Type
text/x-python
Expires
Thu, May 23, 16:15 (2 d)
Engine
blob
Format
Raw Data
Handle
17802423
Attached To
rUVW UVW
data_array.py
View Options
import
numpy
as
np
import
functools
import
operator
class
DataArray
:
"""Class holding information on ndarray"""
def
__init__
(
self
,
data
,
spatial_axes
,
name
=
''
,
components_order
=
'C'
):
self
.
data
=
data
axes
=
list
(
range
(
data
.
ndim
))
for
ax
in
spatial_axes
:
axes
.
remove
(
ax
)
nb_components
=
functools
.
reduce
(
lambda
x
,
y
:
x
*
data
.
shape
[
y
],
axes
,
1
)
if
components_order
==
'C'
:
axes
.
reverse
()
else
:
raise
Exception
(
'Unrecognized components order'
)
axes
+=
spatial_axes
# Hopefully this is a view
self
.
flat_data
=
self
.
data
.
transpose
(
*
axes
)
.
reshape
(
-
1
,
order
=
'F'
)
self
.
attributes
=
{
"Name"
:
name
,
"type"
:
str
(
self
.
flat_data
.
dtype
)
.
capitalize
(),
"NumberOfComponents"
:
str
(
nb_components
)
}
def
__str__
(
self
):
return
self
.
attributes
.
__str__
()
Event Timeline
Log In to Comment