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

@save "foo.jld" doesn't save anything instead of saving everything inside a module #139

Closed
wupeifan opened this issue Feb 23, 2017 · 6 comments

Comments

@wupeifan
Copy link

Julia 0.5, Windows 7, latest version of JLD,

@save "foo.jld"
d = load("foo.jld")
Dict String -> Any with 0 entries

When I use @save "foo.jld" a, it does save a.

@simonster
Copy link
Member

In the code snippet above, you don't define any variables before you call @save, and so @save doesn't save any variables.

Also note that, if you do not specify any variable names, @save will save all global variables, but not any variables local to the current function.

@wupeifan
Copy link
Author

For sure I have a bunch of variables before I call @save. I just didn't put '...' here. I am aware that I am not going to save an empty module.
And I want that to save all global variables inside a module. It is not inside a function. I call it globally under a module.

@simonster
Copy link
Member

Can you provide some code that reproduces the issue?

@wupeifan
Copy link
Author

wupeifan commented Mar 15, 2017

@simonster Sorry I didn't reply quickly.
Yes, here's what I tried, under my current environment.

`
module foo
using JLD
a = 1
@save "foo.jld"
d = load("foo.jld")
end

`

And d is a dictionary with no entries. Instead if I use @save "foo.jld" a, then d has entry a.

@simonster
Copy link
Member

Thanks, that's very useful. It seems that @save currently saves only exported variables from modules other than Main. Perhaps we should change this.

@wupeifan
Copy link
Author

I see. Then that's the way I am using the function is not correct.
Since description of this function says "save the variables like Matlab saving workspace". I was thinking maybe saving inside module is similar.

@wupeifan wupeifan changed the title @save "foo.jld" doesn't save anything instead of saving everything @save "foo.jld" doesn't save anything instead of saving everything inside a module Mar 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants