Reexporting problem types

question
module
design

#1

Inspired by the JuliaDiffEq ecosystem and many other awesome Julia frameworks, I am trying to split my package into a Base package that contains the problem definitions and solution specifications. I have finished a first implementation here: https://github.com/juliohm/GeoStatsBase.jl

Now my question is how to use the concepts in the base package in the implementation packages. For instance, I tried to simply do the following in GeoStats.jl:

module GeoStats

using Reexport

# load problem and solution specifications
@reexport using GeoStatsBase

# instantiate concrete problems defined in GeoStatsBase
EstimationProblem(somedata, somedomain, somevars)

end # module

The module compiles fine, but when I run the tests, whenever the constructor of EstimationProblem is called, I get the following error:

Estimation: Error During Test
  Got an exception of type ErrorException outside of a @test
  not implemented
  Stacktrace:
   [1] Type at /home/juliohm/.julia/v0.6/GeoStatsBase/src/problems/estimation_problem.jl:44 [inlined]
   [2] GeoStatsBase.EstimationProblem(::GeoStats.GeoDataFrame{DataFrames.DataFrame}, ::GeoStats.RegularGrid{Float64,3}, ::Symbol) at /home/juliohm/.julia/v0.6/GeoStatsBase/src/problems/estimation_problem.jl:50
   [3] macro expansion at /home/juliohm/.julia/v0.6/GeoStats/test/problems.jl:6 [inlined]
   [4] macro expansion at ./test.jl:860 [inlined]
   [5] macro expansion at /home/juliohm/.julia/v0.6/GeoStats/test/problems.jl:5 [inlined]
   [6] macro expansion at ./test.jl:860 [inlined]
   [7] anonymous at ./<missing>:?
   [8] include_from_node1(::String) at ./loading.jl:569
   [9] include(::String) at ./sysimg.jl:14
   [10] macro expansion at /home/juliohm/.julia/v0.6/GeoStats/test/runtests.jl:48 [inlined]
   [11] anonymous at ./<missing>:?
   [12] include_from_node1(::String) at ./loading.jl:569
   [13] include(::String) at ./sysimg.jl:14
   [14] process_options(::Base.JLOptions) at ./client.jl:305
   [15] _start() at ./client.jl:371

What I am missing?


#2

I was missing some imports, it is almost there…

Regarding this specific issue of a Base package that contains concrete problem types and other abstract types, what are the necessary statements to load the package?

using GeoStatsBase # brings names into scope for usage
import GeoStatsBase: coordinates, npoints, ... # extend interface with new methods

In my case, the data method for the concrete type EstimationProblem is not visible inside of GeoStats, I had to explicitly call using GeoStatsBase: data in order to bring it to scope, what is the reason?


#3

It’s not exported?


#4

You mean I should reexport it in GeoStats so that it becomes visible in the tests, makes sense! Looking at it again…