Open cossio opened 2 years ago
A workaround is to (also) import the module with its original name.
using BSON
import LinearAlgebra as LA
import LinearAlgebra # we can still refer to LinearAlgebra as LA
e = LA.eigen(randn(5,5))
BSON.@save "temp.bson" e
BSON.@load "temp.bson" e # now works
In the end, I think we'll want to use LinearAlgebra
, etc. so that the BSON file can be loaded by someone else in a totally different environment (unless we figure out a way to resolve both). But maybe we can detect this situation and print out a warning on save?
If I do this:
using BSON
import LinearAlgebra as LA
e = LA.eigen(randn(5,5))
BSON.@save "temp.bson" e
And then, on a fresh Julia session:
using BSON
import LinearAlgebra
BSON.@load "temp.bson" e
This works fine. So on save BSON
is using LinearAlgebra
to identify the module which I think is alright, since that's the explicit name.
Now, if I try loading this file from a session which has import LinearAlgebra as LA
, I get the error. But can't it see that LA
is the same as LinearAlgebra
? Is there a Pkg function or something to get the full name of a module / package?
julia> import LinearAlgebra as LA
julia> fullname(LA)
(:LinearAlgebra,)
I think we can use that, right?
If someone can point out where the relevant code is I can take a look and try to put up a PR using fullname
as above.
Stacktrace: