I would like to create a package for a model that ships with its own internal data. Basically, I’m looking for the Julia equivalent to R’s
I currently have something that looks like this:
module MyModule using Serialization: deserialized export myfunction mydata = deserialize("data/mydata") function myfunction(a, b) a .* mydata[:,1] .+ b .* mydata[:,2] end end
My questions are:
(1) How do I generalize the
data path so it works anywhere? Right now this only works when I’m doing analysis inside the package directory. I would like to be able to install this package from GitHub (via
Pkg.add) and use it in other projects, but when I try to do that, the package install fails because it can’t find the
data directory (because the path is relative to the current directory).
(2) Is the fact that
myfunction uses a variable from outside its scope inefficient (similar to how functions using global variables are inefficient)? Or is it fine because it’s in a module?
mydata here be a