Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pradal opened this issue Oct 22, 2024 · 0 comments
Open

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

pradal opened this issue Oct 22, 2024 · 0 comments
Assignees

Comments

@pradal
Copy link
Contributor

pradal commented Oct 22, 2024

#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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants