Commit 60a4a1ee authored by Klaus Wölfel's avatar Klaus Wölfel

Fix data array preview for 1-d an 0-d arrays

parent 457b2ba3
...@@ -50,7 +50,9 @@ ...@@ -50,7 +50,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string># return columns from shape of axis 1 of ndarray\n <value> <string encoding="cdata"><![CDATA[
# return columns from shape of axis 1 of ndarray\n
# never return more than the first 100 columns\n # never return more than the first 100 columns\n
array = context.getArray()\n array = context.getArray()\n
\n \n
...@@ -58,8 +60,13 @@ if array is None:\n ...@@ -58,8 +60,13 @@ if array is None:\n
return []\n return []\n
\n \n
else:\n else:\n
if len(context.getArrayShape()) < 2:\n
return [(\'index\', \'Index\'), (\'1\', \'1\')]\n
else:\n
return [(\'index\', \'Index\')] + [(str(i), str(i)) for i in range(min(context.getArrayShape()[1], 100))]\n return [(\'index\', \'Index\')] + [(str(i), str(i)) for i in range(min(context.getArrayShape()[1], 100))]\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
......
...@@ -73,11 +73,22 @@ class SequenceSliceMap():\n ...@@ -73,11 +73,22 @@ class SequenceSliceMap():\n
return self.sequence_slice[index % self.length]\n return self.sequence_slice[index % self.length]\n
\n \n
def createTempBase(nr, row):\n def createTempBase(nr, row):\n
column_iterator = enumerate([col for col in context.DataArray_getArrayColumnList() if col[0] != \'index\'])\n def getElementFromArray(array, index):\n
return array[index]\n
\n
def getElementFromScalar(scalar, index=None):\n
return scalar\n
\n
column_list = [col for col in context.DataArray_getArrayColumnList() if col[0] != \'index\']\n
column_iterator = enumerate(column_list)\n
if len(column_list) == 1:\n
getElement = getElementFromScalar\n
else:\n
getElement = getElementFromArray\n
return newTempBase(context.getPortalObject(),\n return newTempBase(context.getPortalObject(),\n
str(id(row)),\n str(id(row)),\n
index = nr,\n index = nr,\n
**{col[0]: str(row[i]) for i, col in column_iterator})\n **{col[0]: str(getElement(row, i)) for i, col in column_iterator})\n
\n \n
\n \n
length = context.getArrayShape()[0]\n length = context.getArrayShape()[0]\n
......
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