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

Add Pluralization of @NLparameters (#2593) #2619

Merged
merged 3 commits into from
Jun 1, 2021
Merged

Add Pluralization of @NLparameters (#2593) #2619

merged 3 commits into from
Jun 1, 2021

Conversation

Pramodh-G
Copy link
Contributor

Fixes Issue #2593 .
Please suggest ways in which this PR can be improved :)

@codecov
Copy link

codecov bot commented May 31, 2021

Codecov Report

Merging #2619 (81f6d23) into master (972b97c) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2619   +/-   ##
=======================================
  Coverage   93.50%   93.50%           
=======================================
  Files          44       44           
  Lines        5544     5544           
=======================================
  Hits         5184     5184           
  Misses        360      360           
Impacted Files Coverage Δ
src/macros.jl 92.96% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 972b97c...81f6d23. Read the comment docs.

Copy link

@patrickocal patrickocal left a comment

Choose a reason for hiding this comment

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

May I suggest that you make clear the syntax for begin ... end blocks:

"Distinct parameters need to be placed on seperate lines without base_names as in the following example."

This is because other objects (such as variables and constraints) can be assigned names.

@Pramodh-G
Copy link
Contributor Author

Sure, I'll update it.

@patrickocal
Copy link

patrickocal commented May 31, 2021 via email

@odow
Copy link
Member

odow commented Jun 1, 2021

What was meant is that somewhere it should be clear that, unlike variables and constraints, parameters cannot be given a name::String.

This is covered in the docstring of @NLparameter: https://jump.dev/JuMP.jl/v0.21.8/reference/nlp/#ref_nl_parameters. Adding extra arguments is a separate issue.

@patrickocal
Copy link

patrickocal commented Jun 1, 2021

We wouldn't want any redundancy now would we :)

I think you're assuming that someone will first learn the singular and then the plural. But things don't always work that way in practice.

The fact that NLparameters is a pluralisation of NLparameter and constructed via a macro is incidental to the way JuMP was built. It has nothing to do with the perspective of the user.

@odow
Copy link
Member

odow commented Jun 1, 2021

We link to the @NLparameter docstring and explain it follows the same syntax. Moreover, the general rule for docstrings is to explain the things that can be done, rather than what can't be done.

Error messages should tell what people did wrong (this isn't the greatest example because it actually looks like a bug!:

julia> @NLparameter(model, p == 1, base_name = "x")
ERROR: LoadError: At REPL[7]:1: `@NLparameter(model, p == 1)`: Too many arguments.
Stacktrace:
 [1] error(::String, ::String)
   @ Base ./error.jl:42
 [2] _macro_error(macroname::Symbol, args::Tuple{Symbol, Expr}, source::LineNumberNode, str::String)
   @ JuMP ~/.julia/dev/JuMP/src/macros.jl:1365
 [3] (::JuMP.var"#_error#122"{LineNumberNode, Symbol, Expr})(str::String)
   @ JuMP ~/.julia/dev/JuMP/src/macros.jl:2114
 [4] var"@NLparameter"(__source__::LineNumberNode, __module__::Module, m::Any, ex::Any, extra::Vararg{Any, N} where N)
   @ JuMP ~/.julia/dev/JuMP/src/macros.jl:2118
in expression starting at REPL[7]:1

Edit: I opened an issue: #2620

@odow odow merged commit 9f02be8 into jump-dev:master Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants