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

Use Doctests #557

Merged
merged 85 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
b7e3adf
Start including doctests
lrennels Sep 30, 2019
4fbffd7
Add doctests to faq
lrennels Oct 1, 2019
76c95d4
Add continuous doctest scope; improve consistency of docs
lrennels Oct 2, 2019
59efb5c
Add doctests to testing suite
lrennels Oct 2, 2019
c4bdefa
Debug doctests
lrennels Oct 2, 2019
42d64e0
Fix typo
lrennels Oct 2, 2019
be5eec4
add blank lines after output
lrennels Oct 2, 2019
878ecd4
Debug doctests, tests passing
lrennels Oct 2, 2019
40f9edd
Add doctests to tutorial 3
lrennels Oct 2, 2019
e8a2fa5
mege master
lrennels Oct 6, 2019
8d14a3c
Add Project.toml packages; add doctests to Tutorial 1
lrennels Oct 6, 2019
0760c0f
Add more doctesting
lrennels Oct 6, 2019
234b02f
Clean up doctests; all tests passing
lrennels Oct 7, 2019
994a2d4
Merge branch 'master' into doctests
lrennels Oct 7, 2019
573322c
Merge branch 'master' into doctests
lrennels Oct 7, 2019
9735f57
start updating tutorial 4
corakingdon Oct 7, 2019
11b355d
Merge branch 'doctests' of https://github.com/mimiframework/Mimi.jl i…
corakingdon Oct 7, 2019
ec8373c
Update Documenter version
lrennels Oct 7, 2019
0c4f2dc
Merge branch 'doctests' of https://github.com/mimiframework/Mimi.jl i…
lrennels Oct 7, 2019
a43f1b1
Merge branch 'master' into doctests
lrennels Oct 8, 2019
306ba46
Use setdocmeta! per v0.23 breaking change
lrennels Oct 8, 2019
62183c0
Merge branch 'master' into doctests
lrennels Oct 8, 2019
4c257fe
Merge branch 'master' into doctests
lrennels Oct 8, 2019
136b0a7
Add using statements to docstrings; metadata not working
lrennels Oct 8, 2019
14d6512
Add compat for Documenter
lrennels Oct 8, 2019
af24d03
Remove Documenter from compat
lrennels Oct 8, 2019
90dfead
Merge branch 'master' into doctests
lrennels Oct 8, 2019
dee6c54
remove include statement from tutorial 4
corakingdon Oct 8, 2019
24627a8
conclude merge
corakingdon Oct 8, 2019
f4ce868
Remvoe doctest from runtests.jl file
lrennels Oct 8, 2019
ec563fa
updates to tutorial_main
corakingdon Oct 8, 2019
2841be9
fix spacing in compdefs
corakingdon Oct 8, 2019
71f9537
rename two-region-model to multi-region-model
corakingdon Oct 8, 2019
9be6f9b
Start updating tutorial 4
corakingdon Oct 8, 2019
150f9ad
Merge branch 'doctests' of https://github.com/mimiframework/Mimi.jl i…
corakingdon Oct 8, 2019
a15233a
more edits to tutorial 4
corakingdon Oct 8, 2019
f7f7f00
Various updates to doctests
lrennels Oct 9, 2019
47a411f
Use Julia 1.2 for doc build
davidanthoff Oct 9, 2019
e07ee03
Tweak travis script
davidanthoff Oct 9, 2019
57b679d
Fix travis
davidanthoff Oct 9, 2019
165b937
Include newlines in filters; fix bug
lrennels Oct 9, 2019
ee38231
small edits to tutorials 1 and 2
corakingdon Oct 10, 2019
771692d
Merge branch 'master' into doctests
lrennels Oct 10, 2019
643adb5
Fix doctest; udpate reference.md
lrennels Oct 11, 2019
94bc5c3
remove doctest filter on one block
corakingdon Oct 11, 2019
6853786
Try running doctests from make.jl
lrennels Oct 11, 2019
7bbb36d
Merge master
lrennels Nov 9, 2019
8570ae8
Update FUND version
lrennels Nov 9, 2019
95371d0
Fix typo; Add filter to supress deprecation warnings
lrennels Nov 9, 2019
75e0c07
Fix typo
lrennels Nov 9, 2019
808df07
Add missing docstrings for reference.md
lrennels Nov 10, 2019
a890f7c
Fix typo
lrennels Nov 10, 2019
b4f7039
Use getdataframe for simulation instance
lrennels Nov 10, 2019
0f3e340
Remove explicit doctest call from make.jl
lrennels Nov 10, 2019
da02eec
Test that Travis doctests fail
lrennels Nov 10, 2019
c9be343
Merge branch 'doctests' of https://github.com/mimiframework/Mimi.jl i…
lrennels Nov 10, 2019
47d55e9
Add test to see if Travis will fail doctestS
lrennels Nov 10, 2019
bc7e8d6
Remove bug tests.
lrennels Nov 10, 2019
0a137d1
Change makedocs strict setting to true
lrennels Nov 10, 2019
37f7820
Merge branch 'doctests' of https://github.com/mimiframework/Mimi.jl i…
lrennels Nov 10, 2019
a3771be
Move doctesting to outside of makedocs
lrennels Nov 10, 2019
b72afbd
Fix minor typos
corakingdon Nov 11, 2019
7bcb1a7
Remove uncessary compats from docs Project.toml
corakingdon Nov 11, 2019
0d784be
Remove MimiFUND compat in docs
corakingdon Nov 12, 2019
9331ef4
Move `doctest(Mimi)` into test suite
corakingdon Nov 12, 2019
77f0330
Fix doctest setup
corakingdon Nov 13, 2019
b170208
Merge branch 'master' into doctests
lrennels Nov 15, 2019
9ad3547
Update travis.yml file
lrennels Nov 15, 2019
01ef1fa
missing quote
corakingdon Nov 18, 2019
e4b0b96
Move doctest to botto of testing suite file
lrennels Nov 18, 2019
4f478cf
Merge branch 'doctests' of https://github.com/mimiframework/Mimi.jl i…
lrennels Nov 18, 2019
2902d7d
Remove doctesting of explore function
lrennels Nov 19, 2019
04d54ab
Add # output line to fix bug
lrennels Nov 19, 2019
12af5e2
Merge branch 'master' into doctests
davidanthoff Nov 23, 2019
723a3aa
Move doctest call
davidanthoff Nov 23, 2019
7198310
Add MimiRegistry in build on gh
davidanthoff Nov 23, 2019
cc8e704
Try new strategy for package install
davidanthoff Nov 23, 2019
f793174
Fix bug in Project.toml
davidanthoff Nov 23, 2019
6fb320a
Fix a doctest bug
davidanthoff Nov 23, 2019
473ff22
Rearrange some code
davidanthoff Nov 23, 2019
b7f62ab
Merge branch 'master' into doctests
davidanthoff Nov 23, 2019
40cdff3
Merge branch 'master' into doctests
davidanthoff Nov 26, 2019
a570d75
Doctest dataframes instead of arrays
lrennels Nov 26, 2019
17c17f7
Merge branch 'doctests' of https://github.com/mimiframework/Mimi.jl i…
lrennels Nov 26, 2019
f8010bc
Merge branch 'master' into doctests
lrennels Nov 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Mimi = "e4e893b0-ee5e-52ea-8111-44b3bdec128c"

[compat]
Distributions = "0.21"
Documenter = "~0.21"
Mimi = "0.9.3"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be Mimi 0.9.4?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or actually wouldn't we need it to be the 0.9.5-dev version? I guess this is a broader question I have about whether or not our documentation is supposed to be compatible with the latest released version, or with master. I think that the version of documentation that lives on https://www.mimiframework.org/Mimi.jl/stable/ only shows the documentation for the latest released version right? So that means we should always have our documentation up to date with master, but it won't actually display until a new release of Mimi happens?

If all of that is true, then I think the version of Mimi that we want in the Project.toml would be master, but I'm not sure how to specify that

Copy link
Collaborator Author

@lrennels lrennels Nov 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the version of the documentation that lives in the stable link only shows documentation for the latest tagged/released version of Mimi, so the documentation might as well keep up with master. I think 0.9.4 is probably good enough but I guess eager would be idea? @davidanthoff?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should remove all entries other than Documenter itself from here. Documenter should be specified as ~0.23.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the ~ mean? I think we also need to keep MimiFUND at at least 3.11.9, so would that also need to be MimiFUND = "~3.11.9" here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://julialang.github.io/Pkg.jl/v1/compatibility/#Caret-specifiers-1

So I actually think it doesn't matter whether we use caret or tilde for Documenter, we should just specify one of them.

For FUND, if there is a minimal version we require we can just say MimiFUND = "3.11.9". But do we need that? It will just grab the latest version if we don't specify anything, which is what we want, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but for FUND, I think we should actually not use the tilde operator, otherwise we potentially pin FUND to old versions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we shouldn't have to specify FUND then. But why do we have to specify for Documenter then?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They might release a breaking release, and we would want to opt in to get that.

73 changes: 61 additions & 12 deletions docs/src/faq.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Frequently asked questions

```@meta
DocTestSeup =
using Mimi
using Distributions
end
```
## What's up with the name?

The name is probably an acronym for "Modular Integrated Modeling Interface", but we are not sure. What is certain is that it came up during a dinner that [Bob](http://www.bobkopp.net/), [David](http://www.david-anthoff.com/) and [Sol](http://www.solomonhsiang.com/) had in 2015. David thinks that Bob invented the name, Bob doesn't remember and Sol thinks the waiter might have come up with it (although we can almost certainly rule that option out). It certainly is better than the previous name "IAMF". We now use "Mimi" purely as a name of the package, not as an acronym.
Expand All @@ -11,21 +17,44 @@ covariance between estimated coefficient parameters. For example, an estimated
polynomial can be represented as a multivariate Normal distribution,
with a variance-covariance matrix. To use this, define the parameter
in the component with a vector type, like here:
```
@defcomp example begin
cubiccoeffs::Vector{Float64} = Parameter()

```jldoctest; output = false
@defcomp MyComp begin
cubiccoeff::Vector{Float64} = Parameter()
end

# output
```

Then in the model construction, set the parameter with a multivariate
distribution (here the parameters are loaded from a CSV file):
```
cubicparams = readdlm("../data/cubicparams.csv", ',')
set_param!(m, :example, :cubiccoeff, MvNormal(squeeze(cubicparams[1,:], 1), cubicparams[2:4,:]))
distribution:

```jldoctest; output = false; setup = @defcomp MyComp begin cubiccoeff::Vector{Float64} = Parameter() end
# First line: linear, quadratic, cubic
# Lines 2-4: covariance matrix
cubicparams = [
[-3.233303 1.911123 -0.1018884];
[ 1.9678593 -0.57211657 0.04413228];
[-0.57211657 0.17500949 -0.01388863];
[ 0.04413228 -0.01388863 0.00111965]
]

m = Model()
set_dimension!(m, :time, collect(2015:5:2110))
add_comp!(m, MyComp)

set_param!(m, :MyComp, :cubiccoeff, MvNormal(cubicparams[1,:], cubicparams[2:4,:]))

# output
```

Here, `../data/cubicparams.csv` is a parameter definition file that looks something like this:
Note that we could also load the data fom a file with:

```julia
cubicparams = readdlm("../data/cubicparams.csv", ',')
```
where `../data/cubicparams.csv` would be a parameter definition file that looks something like this:
```julia
# Example estimated polynomial parameter
# First line: linear, quadratic, cubic
# Lines 2-4: covariance matrix
Expand All @@ -38,13 +67,29 @@ Here, `../data/cubicparams.csv` is a parameter definition file that looks someth
## How do I use component references?

Component references allow you to write cleaner model code when connecting components. The `add_comp!` function returns a reference to the component that you just added:
```
mycomponent = add_comp!(model, MyComponent)

```jldoctest; output = false; setup = @defcomp MyComp begin cubiccoeff::Vector{Float64} = Parameter() end
m = Model()
set_dimension!(m, :time, collect(2015:5:2110))

mycomponent = add_comp!(m, MyComp)

# output
Mimi.ComponentReference(1-component Mimi.Model:
MyComp::Main.MyComp
, :MyComp)
```

If you want to get a reference to a component after the `add_comp!` call has been made, you can construct the reference as:
```
mycomponent = ComponentReference(model, :MyComponent)
```jldoctest; setup = @defcomp MyComp begin cubiccoeff::Vector{Float64} = Parameter() end; m = Model(); set_dimension!(m, :time, collect(2015:5:2110)); add_comp!(m, MyComp)

mycomponent = Mimi.ComponentReference(m, :MyComp)

#output
Mimi.ComponentReference(1-component Mimi.Model:
MyComp::Main.MyComp
, :MyComp)

```

You can use this component reference in place of the `set_param!` and `connect_param!` calls.
Expand All @@ -56,3 +101,7 @@ The line `set_param!(model, :MyComponent, :myparameter, myvalue)` can be written
## References in place of `connect_param!`

The line `connect_param!(model, :MyComponent, :myparameter, :YourComponent, :yourparameter)` can be written as `mycomponent[:myparameter] = yourcomponent[:yourparameter]`, where `mycomponent` and `yourcomponent` are component references.

```@meta
DocTestSetup = nothing
```