From 4b68fafb8b616c85f0f684622cb9d382e541cb60 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 9 Feb 2018 19:58:57 +1300 Subject: [PATCH 1/2] Clarity get/set! when canget/set returns false --- src/attributes.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/attributes.jl b/src/attributes.jl index c48a850dc0..ba64123f24 100644 --- a/src/attributes.jl +++ b/src/attributes.jl @@ -97,6 +97,11 @@ If an `F`-in-`S` constraint with name `name` exists in the instance `instance`, If *any* constraint with name `name` exists in the instance `instance`, 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` may throw an error or return an incorrect result. + ### Examples ```julia @@ -227,6 +232,11 @@ Assign a value to the attribute `attr` of constraint `c` in instance `instance`. set!(instance::AbstractInstance, 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 instance `instance`. + +### Note + +It is the user's responsibility to check that `canset` returns `true` prior to calling `set!`. +Calling `set!` when `canset` returns `false` may throw an error or do nothing. """ function set! end function set!(instance::AbstractInstance, attr::AnyProperty, args...) From 8cd411ffb4b6377c98d28a1848e73b9e0e95f1f7 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 14 Feb 2018 10:04:12 +1300 Subject: [PATCH 2/2] Update attributes.jl --- src/attributes.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/attributes.jl b/src/attributes.jl index ba64123f24..f7518f850c 100644 --- a/src/attributes.jl +++ b/src/attributes.jl @@ -100,7 +100,7 @@ If *any* constraint with name `name` exists in the instance `instance`, return t ### Note It is the user's responsibility to check that `canget` returns `true` prior to calling `get`. -Calling `get` when `canget` returns `false` may throw an error or return an incorrect result. +Calling `get` when `canget` returns `false` will throw an error. ### Examples @@ -236,7 +236,7 @@ Assign a value respectively to the attribute `attr` of each constraint in the co ### Note It is the user's responsibility to check that `canset` returns `true` prior to calling `set!`. -Calling `set!` when `canset` returns `false` may throw an error or do nothing. +Calling `set!` when `canset` returns `false` will throw an error. """ function set! end function set!(instance::AbstractInstance, attr::AnyProperty, args...)