Skip to content

[Python] Array are not allocated correctly in functions #242

Open
@pradal

Description

#Transpilation from Python to Crop2ML

When an array is defined in a model everything is OK.
For instance

soilConstituentNames : 'Array[str]' = ["Rocks", "OrganicMatter"]

is transformed in

cdef str soilConstituentNames[]
soilConstituentNames=["Rocks", "OrganicMatter"]

But when arrays are defined in functions, the initialisation is missing

thermalCondPar1 : 'Array[float]'=  [0.0]*(numNodes + 1)

leads to

cdef float thermalCondPar1[]

Workaround

Declare the arry on two lines

thermalCondPar1 : 'Array[float]'
thermalCondPar1=  [0.0]*(numNodes + 1)

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions