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

Warning on attempt to save anonymous function #175

Open
thisrod opened this issue Jan 21, 2020 · 2 comments
Open

Warning on attempt to save anonymous function #175

thisrod opened this issue Jan 21, 2020 · 2 comments

Comments

@thisrod
Copy link
Contributor

thisrod commented Jan 21, 2020

Consider the following.

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using JLD2

julia> A = Any[x->x]
1-element Array{var"#7#8",1}:
 var"#7#8"()

julia> @save "A.jld2" A

julia> exit()
$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using JLD2

julia> @load "A.jld2" A
┌ Warning: type Main.#9#10 does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/dev/JLD2/src/data.jl:1066
1-element Array{Symbol,1}:
 :A

I understand that it will never be practical to save anonymous functions in a HDF file. However, it would be helpful if @save raised a warning when you tried to do that.

Among other things, it would save users from repeatedly raising this issue.

I ran across this when I tried to save a DifferentialEquations.ODESolution. That is the kind of thing you want to save, and it would be nice to get a warning when the ODESolution for dx/dt = f(t,x) includes f as an anonymous function. Unless you read the source of DifferentialEquations, there is no reason you would guess that it did.

Related issues: #13 #86

@TS-CUBED
Copy link

TS-CUBED commented Jul 20, 2021

I ran across this when I tried to save a DifferentialEquations.ODESolution. That is the kind of thing you want to save, and it would be nice to get a warning when the ODESolution for dx/dt = f(t,x) includes f as an anonymous function. Unless you read the source of DifferentialEquations, there is no reason you would guess that it did.

Hmm, that explains my problem. However, a warning that I'm saving an anonymous function is not really a solution to the problem that we'd still want (need!) to save a DifferentialEquations.ODESolution.

Do I understand correctly, that this issue will be fixed with #316

@JonasIsensee
Copy link
Collaborator

This will be fixed with #316 .
However, there is still quite some work to do,
in particular, since methods changed from 1.6 to 1.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants