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

Clarity get/set! when canget/set returns false #210

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions src/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ If an `F`-in-`S` constraint with name `name` exists in the model `model`, return

If *any* constraint with name `name` exists in the model `model`, return the corresponding index, otherwise throw a `KeyError`. This version is available for convenience but may incur a performance penalty because it is not type stable.

### Note

It is the user's responsibility to check that `canget` returns `true` prior to calling `get`.
Calling `get` when `canget` returns `false` will throw an error.
Copy link
Member

Choose a reason for hiding this comment

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

This is now a weird statement. Do we need to add this note for addconstraint! modifyconstraint!, etc (anything that as a corresponding canXXX)?
I would phrase it more of a note for implementations. These functions must throw errors if the corresponding canXXX returned false.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should this just be a general note in the manual then?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, could be in the section on notes for solver wrappers.


### Examples

```julia
Expand Down Expand Up @@ -225,6 +230,11 @@ Assign a value to the attribute `attr` of constraint `c` in model `model`.
set!(model::ModelLike, attr::AbstractConstraintAttribute, c::Vector{ConstraintIndex{F,S}}, vector_of_values)

Assign a value respectively to the attribute `attr` of each constraint in the collection `c` in model `model`.

### Note

It is the user's responsibility to check that `canset` returns `true` prior to calling `set!`.
Calling `set!` when `canset` returns `false` will throw an error.
"""
function set! end
# See note with get
Expand Down