An expression that can be used:
dinamica.package("numpy") a = numpy.arange(15).reshape(3, 5) print(a) print(dinamica.inputs) for row in dinamica.inputs["t1"]: print(row) for row in dinamica.inputs["t2"]: print(row) dinamica.outputs["teste"] = 2 dinamica.outputs["teste2"] = 2.5 dinamica.outputs["teste3"] = 'a' dinamica.outputs["outraSaida"] = "yoyo" dinamica.outputs["tabela"] = dinamica.prepareTable(dinamica.inputs["t1"], 3) dinamica.outputs["lut"] = dinamica.prepareLookupTable(dinamica.inputs["t2"])
where:
dinamica.package("numpy")
Ask the PIP to install the numpy package and import it:
print(dinamica.inputs)
Prints the vector with all the entries passed by Dinamica:
dinamica.outputs["teste2"] = 2.5
Place an output in the struct named “test2”, containing a double with a value of 2.5:
dinamica.outputs["tabela"] = dinamica.prepareTable(dinamica.inputs["t1"], 3)
Place an output in the struct named “table”, containing a table with 3 key columns. This function is not necessary if the table already has '*' in the column names (so the user could only do dinamica.outputs [“teste2”] = dinamica.inputs [“t1”]). Every table in Python is treated as a list of lists, where each internal list corresponds to a row of the table:
dinamica.outputs["lut"] = dinamica.prepareLookupTable(dinamica.inputs["t2"])
Put an output in the struct named “lut”, containing a LookupTable (There is no other way to pass a LookupTable back):
Utility Name | Description | Parameters |
---|---|---|
package | It imports the module requested. | str packageName, str installPath=None, str loadPath=None |
prepareTable | It returns the table prepared to output. Input Table has to be in the form [header1...headerN][line1]...[lineM] where the first list contains the headers of the table and all the other lists are lines containing the data. | list(list) inputTable, int numKeys |
prepareLookupTable | It returns the lookup table prepared to output. The lut has to be in the form [key,value][line1]...[lineM] where the first list contains the headers of the table and all the other lists are lines containing the data. | list(list) lut |
toTable | It returns a valid representation of dinamica table to output. Input Table can be: [header1...headerN][line1]...[lineM] where the first list contains the headers of the table and all the other lists are lines containing the data; {header1: [valuesOfColumn1], header2: [valuesOfColumn2]…} where the valuesOfComlumn# are all values of that column in table; (header1...headerN)(line)...(lineM) where the first tuple contains the headers of the table and all the other tuples are lines containing the data; [value1, value2, …, valueN], those are the values for a lookup table with sequential key; pandas.Dataframe is a commom structure table used to manipulate CSVs; numpy.array is a commom structure for matrix, that can be tables as well. The first line of matrix needs to be the table header. | list(list);dict(list);list(tuple);list;pandas.DataFrame;numpy.array inputTable |
See the documentation about Calculate Python Expression for further information about to use Python together with Dinamica EGO.