Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
calculate_python_expression [2026/07/22 03:32]
hermann
calculate_python_expression [2026/07/22 18:15] (current)
hermann
Line 57: Line 57:
 | [[Extract Struct Tuple]] | A tuple value | | [[Extract Struct Tuple]] | A tuple value |
  
-Each functor takes two inputs: the ''​Struct''​ returned by ''​CalculatePythonExpression'',​ and the name of the entry to extract as a string constant. For example, to retrieve a numeric output named ''​patchCount''​ and a table output named ''​filteredPatches'':​+Each functor takes two inputs: the ''​Struct''​ returned by ''​CalculatePythonExpression'',​ and the name of the entry to extract as a string constant. For example, to retrieve a numeric output named ''​patchCount''​ and a table output named ''​filteredPatches'' ​— the ''​String $"​(...)"''​ wrapper around the Python code is explained in [[#​writing_the_expression_in_ego_script|Writing the expression in EGO Script]] below:
  
 <​code>​ <​code>​
Line 110: Line 110:
  
 The //​packages//​ port takes one package identifier per line, in any form accepted by ''​pip''​. It only installs — unlike ''​dinamica.package()'',​ it does not also import the module, and it does not support specifying a separate install name and import name. Every listed package is installed before the expression runs, but the expression must still import each one itself, using its actual importable name (which may differ from the name given to ''​pip''​):​ The //​packages//​ port takes one package identifier per line, in any form accepted by ''​pip''​. It only installs — unlike ''​dinamica.package()'',​ it does not also import the module, and it does not support specifying a separate install name and import name. Every listed package is installed before the expression runs, but the expression must still import each one itself, using its actual importable name (which may differ from the name given to ''​pip''​):​
 +
 +The //​packages//​ port:
 <​code>​ <​code>​
 numpy numpy
Line 116: Line 118:
 </​code>​ </​code>​
  
 +The expression:
 <​code>​ <​code>​
 import numpy import numpy
Line 124: Line 127:
 === dinamica.prepareTable() === === dinamica.prepareTable() ===
  
-Converts a list of lists into a table ready to be assigned to an output. The first inner list must be the header row.+Converts a list of lists into a table ready to be assigned to an output. The first inner list must be the header row. As with any table (see [[ego_script#​constants|Constants]]),​ each column'​s type is inferred from its own values: a column of ''​int''/''​float''​ values produces a Real column, a column of ''​str''​ values produces a String column.
  
 ^ Parameter ^ Type ^ Default ^ Description ^ ^ Parameter ^ Type ^ Default ^ Description ^
Line 132: Line 135:
 === dinamica.prepareLookupTable() === === dinamica.prepareLookupTable() ===
  
-Converts a list of lists into a lookup table ready to be assigned to an output. The first inner list must be the header row.+Converts a list of lists into a lookup table ready to be assigned to an output. The first inner list must be the header row. Lookup tables are always Real-typed on both key and value sides — there is no String option — so every value in ''​lut''​ must be numeric.
  
 ^ Parameter ^ Type ^ Default ^ Description ^ ^ Parameter ^ Type ^ Default ^ Description ^
Line 139: Line 142:
 === dinamica.toTable() === === dinamica.toTable() ===
  
-Converts several Python data shapes into a valid Dinamica table for output.+Converts several Python data shapes into a valid Dinamica table for output. Column types are inferred the same way as ''​dinamica.prepareTable()''​ — except for a flat list, which always produces a Real-typed lookup table with sequential keys, matching the Real-only rule for lookup tables.
  
 ^ Parameter ^ Type ^ Default ^ Description ^ ^ Parameter ^ Type ^ Default ^ Description ^
Line 274: Line 277:
  
 CalculatePythonExpression CalculatePythonExpression
- 
-