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

enable preview of structured arrays

parent fb4333c4
...@@ -122,6 +122,13 @@ class DataArray(BigFile): ...@@ -122,6 +122,13 @@ class DataArray(BigFile):
""" """
return self.getArray().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') security.declareProtected(Permissions.View, 'index_html')
def index_html(self, REQUEST, RESPONSE, format=_MARKER, inline=_MARKER, **kw): def index_html(self, REQUEST, RESPONSE, format=_MARKER, inline=_MARKER, **kw):
""" """
......
# return columns from shape of axis 1 of ndarray # 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 # never return more than the first 100 columns
array = context.getArray() array = context.getArray()
...@@ -6,7 +7,9 @@ if array is None: ...@@ -6,7 +7,9 @@ if array is None:
return [] return []
else: 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')] return [('index', 'Index'), ('1', '1')]
else: else:
return [('index', 'Index')] + [(str(i), str(i)) for i in range(min(context.getArrayShape()[1], 100))] 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