You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to use JLD within a package to save custom types from that same package. What's the correct way to do this? Call the package itself from within addrequire() (which causes an error if I do it as below)? Or should the package in addrequire() be a lighter-weight types-only package? Is there a performance hit if it's the former?
i.e. within the package ThisPackage, this errors
jldopen(filepath, "w") do file
addrequire(file,ThisPackage)
write(file, "x", x)
end
ERROR: UndefVarError: module_parent not defined
Stacktrace:
[1] _istoplevel(::Module) at C:\Users\IanB\.julia\packages\JLD\1BoSz\src\JLD.jl:1253
[2] addrequire(::JLD.JldFile, ::Module) at C:\Users\IanB\.julia\packages\JLD\1BoSz\src\JLD.jl:1256...
The text was updated successfully, but these errors were encountered:
Also, is there any reason to not do this with JLD, over HDF5.jl etc.? I'm using JLD as there were examples, and I couldn't immediately find how to use custom types in HDF5
Have the same issue, gives me ERROR: LoadError: UndefVarError: module_parent not defined error. Test code attached.
debugCode.jl:
using JLD
push!(LOAD_PATH, pwd());
import debugTypes: Type1, Type2
import debugTypes
a = Type1(3.14);
b = Type2(100.0);
filepath = "test_data.jld"
jldopen(filepath,"w") do file
addrequire(file, debugTypes)
write(file, "a", a, "b", b)
end
debugTypes.jl:
module debugTypes
using Dates
export Type1, Type2
mutable struct Type1
var1::Float64
end
struct Type2
var2::Float64
end
end
I'd like to use JLD within a package to save custom types from that same package. What's the correct way to do this? Call the package itself from within
addrequire()
(which causes an error if I do it as below)? Or should the package inaddrequire()
be a lighter-weight types-only package? Is there a performance hit if it's the former?i.e. within the package
ThisPackage
, this errorsThe text was updated successfully, but these errors were encountered: