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

Inability to save output #93

Closed
kwootton opened this issue Feb 28, 2020 · 4 comments
Closed

Inability to save output #93

kwootton opened this issue Feb 28, 2020 · 4 comments

Comments

@kwootton
Copy link

kwootton commented Feb 28, 2020

Expected behavior

I have run the simulations and now want to save the output - ideally in a form where I can read it into R.

Actual behavior

If I run BioEnergeticFoodWebs.save(filename, as = json) I don't get any error, but I also don't get any output.

If I try JSON.print(f,sim) I get the error:
ERROR: Cannot serialize type getfield(BioEnergeticFoodWebs, Symbol("##10#14"))

JSON.print used to work for me fine a year or two ago so I guess there's some issue with an update somewhere along the line?

Steps to reproduce

1.using BioEnergeticFoodWebs, JSON
2.foodweb = nichemodel(10,0.3);
3.bm = rand(size(foodweb,1));
4. params = model_parameters(foodweb)
5. sim = simulate(params, bm, start = 0, stop = 1000);
6.f=open("trial.json","w")
7.JSON.print(f,sim)

System information

  • julia --version
    julia version 1.1.0 (but I have the same problem with 1.0.5)

  • Pkg.status("BioEnergeticFoodWebs")
    BioEnergeticFoodWebs v1.1.2

  • OS and version
    Ubuntu 18.04.4 LTS (Bionic Beaver)

@tpoisot
Copy link
Member

tpoisot commented Mar 9, 2020

@evadelmas any idea what this is?

@kwootton the line to save in JSON should have as = :json , the : is very important here, can you check it was included?

@evadelmas evadelmas mentioned this issue Mar 10, 2020
@evadelmas
Copy link
Collaborator

Sorry for the delay. It's fixed now and should be released in the next few days.

This was caused by JSON not being able to convert some parameters to strings (i.e. density dependent mortality for consumers and resources - dp and dc - because they are functions). They will now be saved as string(@code_lowered ...)

@kwootton
Copy link
Author

Great, thank you!

@evadelmas
Copy link
Collaborator

Closed by #98

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

3 participants