Commit e816e4d6 authored by Klaus Wölfel's avatar Klaus Wölfel

enable preview of structured arrays

parent fb4333c4
......@@ -121,6 +121,13 @@ class DataArray(BigFile):
Get numpy array dtype
"""
return self.getArray().dtype
security.declareProtected(Permissions.AccessContentsInformation, 'getArrayDtypeNames')
def getArrayDtypeNames(self):
"""
Get numpy array dtype names
"""
return self.getArray().dtype.names
security.declareProtected(Permissions.View, 'index_html')
def index_html(self, REQUEST, RESPONSE, format=_MARKER, inline=_MARKER, **kw):
......
# return columns from shape of axis 1 of ndarray
# if it is a structured array, set column names from dtype
# never return more than the first 100 columns
array = context.getArray()
......@@ -6,7 +7,9 @@ if array is None:
return []
else:
if len(context.getArrayShape()) < 2:
if context.getArrayDtypeNames() is not None:
return [('index', 'Index')] + [(str(i), str(i)) for i in context.getArrayDtypeNames()]
elif len(context.getArrayShape()) < 2:
return [('index', 'Index'), ('1', '1')]
else:
return [('index', 'Index')] + [(str(i), str(i)) for i in range(min(context.getArrayShape()[1], 100))]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment