-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
RFC: more docs #1436
RFC: more docs #1436
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1436 +/- ##
==========================================
+ Coverage 89.22% 89.28% +0.05%
==========================================
Files 26 26
Lines 3723 3723
==========================================
+ Hits 3322 3324 +2
+ Misses 401 399 -2
Continue to review full report at Codecov.
|
The output of the doctests on Travis seem to indicate failures: =====[Test Error]==============================
Wouldn't it be preferable to put the |
Urgh, this is some platform issue. For me, the docs build locally on v0.6 without errors. |
docs/src/variables.md
Outdated
@@ -130,9 +135,9 @@ In the above examples, `x_free` represents an unbounded optimization variable, | |||
`@variable(model, a <= x)`) will result in an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a=1
above should be a = 1
according to the style guide
docs/src/quickstart.md
Outdated
familiar with another modeling language embedded in a high-level language such | ||
as PuLP (Python) or a solver-specific interface you will find most of this | ||
familiar, with the exception of *macros*. A deep understanding of macros is not | ||
essential, but if you would like to know more please see the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading this, it seems to me that it would be a good idea to first understanding macros while this really not a good idea to learn metaprogramming to use JuMP. This might discourage many users. I don't know if essential is the weak enough, maybe "needed" or "required" ? Not sure :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that pointer to macros is a bit out of place. The quick-start guide should be a gentle introduction that shows how to get a few basic things done using JuMP.
docs/src/quickstart.md
Outdated
``` | ||
!!! note | ||
Your model doesn't have to be called `model` - it's just a name. However, | ||
the JuMP style guide prefers `model`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add add href to the style guide here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second sentence is maybe too much information. The style guide doesn't have an explicit preference for model
, just a suggestion to avoid one-letter variable names.
docs/src/quickstart.md
Outdated
DocTestFilters = r"JuMP\." | ||
``` | ||
!!! note | ||
Your model doesn't have to be called `model` - it's just a name. However, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't -> does not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want to allow shortening or not in fact. If you think it is more friendly then I am ok to leave it :)
DocTestSetup = nothing | ||
``` | ||
|
||
Next we'll set our objective. Note again the `model`, so we know which model's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll -> we will
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I started reading the Google documentation style guide. They recommend using contractions: https://developers.google.com/style/contractions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok let's follow Google's style guideline for contraction
docs/src/quickstart.md
Outdated
familiar with another modeling language embedded in a high-level language such | ||
as PuLP (Python) or a solver-specific interface you will find most of this | ||
familiar, with the exception of *macros*. A deep understanding of macros is not | ||
essential, but if you would like to know more please see the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that pointer to macros is a bit out of place. The quick-start guide should be a gentle introduction that shows how to get a few basic things done using JuMP.
docs/src/quickstart.md
Outdated
as PuLP (Python) or a solver-specific interface you will find most of this | ||
familiar, with the exception of *macros*. A deep understanding of macros is not | ||
essential, but if you would like to know more please see the | ||
[Julia documentation](http://docs.julialang.org/en/latest/manual/metaprogramming/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Link to versioned docs.
docs/src/quickstart.md
Outdated
``` | ||
!!! note | ||
Your model doesn't have to be called `model` - it's just a name. However, | ||
the JuMP style guide prefers `model`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second sentence is maybe too much information. The style guide doesn't have an explicit preference for model
, just a suggestion to avoid one-letter variable names.
docs/src/quickstart.md
Outdated
it! Feel free to stick with `*` if it makes you feel more comfortable, as we | ||
have done with `3*y`: | ||
```jldoctest quickstart_example | ||
julia> @objective(model, Max, 5x + 3*y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style guide recommends spaces around binary operators, so 3 * y
.
docs/src/quickstart.md
Outdated
``` | ||
In this case, `GLPK` returned `Success`. This does not mean that it has found | ||
the optimal solution. Instead, it indicates that GLPK has finished running and | ||
did not encounter any errors or termination limits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: user-provided termination limits
docs/src/variables.md
Outdated
@@ -130,9 +135,9 @@ In the above examples, `x_free` represents an unbounded optimization variable, | |||
`@variable(model, a <= x)`) will result in an error. | |||
|
|||
**Extra for experts:** the reason for this is that at compile time, JuMP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole note is maybe too much information. I don't remember anyone ever being confused by why @variable(model, a <= x)
doesn't work. The error message should be helpful enough to figure it out if it ever happens.
docs/src/variables.md
Outdated
MathOptInterface | ||
``` | ||
|
||
To delete variables, we can use the `MOI.delete!` method. We can also check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's implement JuMP.delete!
and JuMP.is_valid
instead of documenting the MOI way.
We're good to go on my end. Doctests pass on v0.6. Annoyingly, they fail on v0.7 because it does not print the module that defines the type. For example, v0.6 will print |
Could we run the doctests on only one version of Julia? Might as well
switch to 1.0 unless there's something blocking it.
…On Sat, Sep 1, 2018, 02:37 Oscar Dowson ***@***.***> wrote:
Doctests pass on v0.6. Annoyingly, they fail on v0.7 because it does not
print the module that defines the type. For example, v0.6 will print
JuMP.VariableRef whereas v0.7 prints VariableRef. However, Documenter
only has the ability to filter output that appears in both the docs and
actual output.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1436 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABp0M2oYbPCzgzI2IAt8KtgqbQrSZYf6ks5uWisxgaJpZM4WI1so>
.
|
|
||
julia> for key in [:A, :B] | ||
variables[key] = @variable(model, [1:2, 1:2], Symmetric) | ||
global variables[key] = @variable(model, [1:2, 1:2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still can't believe that this global
is necessary.
Doctests now run only on v1.0 and pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the slow review... was on vacation.
docs/src/quickstart.md
Outdated
it! Feel free to stick with `*` if it makes you feel more comfortable, as we | ||
have done with `3 * y`: | ||
```jldoctest quickstart_example | ||
julia> @objective(model, Max, 5x + 3 * y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe point out that this example is intentionally inconsistent, but it's good practice to use one way or the other consistently in your code.
docs/src/quickstart.md
Outdated
less-than-or-equal-to constraint using `<=`, but we can also create equality | ||
constraints using `==` and greater-than-or-equal-to constraints with `>=`: | ||
```jldoctest quickstart_example; filter=r"≤|<=" | ||
julia> con = @constraint(model, 1x + 5y <= 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use the anonymous constraint syntax here and the named variable syntax above? (I'd recommend using the named constraint syntax for consistency.)
docs/src/quickstart.md
Outdated
julia> JuMP.termination_status(model) | ||
Success::TerminationStatusCode = 0 | ||
``` | ||
In this case, `GLPK` returned `Success`. This does not mean that it has found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emphasis on not
docs/src/variables.md
Outdated
@@ -44,6 +44,10 @@ This code does three things: | |||
To reduce confusion, we will attempt, where possible, to always refer to | |||
variables with their corresponding prefix. | |||
|
|||
!!! warn | |||
If you create two JuMP variables with the same name, an error will be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More directly: "Creating two JuMP variables with the same name results in an error at runtime."
docs/src/variables.md
Outdated
Because `y` is a Julia variable, I can bind it to a different value. For example, | ||
if I go: | ||
Because `y` is a Julia variable, we can bind it to a different value. For | ||
example, if we go: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"if we go" sounds a bit too informal and might be confusing for non-native speakers. "if we write" instead?
We're not paying you enough to need to apologize... |
Continuation of my doc-writing quest in order to learn the new JuMP syntax.
The majority of the quickstart is borrowed from https://github.com/JuliaOpt/JuMP.jl/blob/v0.18.2/doc/example.rst
The most contentious change is that I added GLPK to travis so that we have a solver for the doc tests.We now use a mock optimizer.