Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Oct 29, 2023
1 parent a379199 commit cc57d09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
20 changes: 10 additions & 10 deletions src/Bridges/bridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ end

function _attribute_error_message(attr, bridge, action)
return "Bridge of type `$(nameof(typeof(bridge)))` does not support " *

Check warning on line 123 in src/Bridges/bridge.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/bridge.jl#L122-L123

Added lines #L122 - L123 were not covered by tests
"$action the attribute `$attr`. If you encountered this error " *
"unexpectedly, it probably means your model has been " *
"reformulated using the bridge, and you are attempting to query " *
"an attribute that we haven't implemented yet for this bridge. " *
"Please open an issue at https://github.com/jump-dev/MathOptInterface.jl/issues/new " *
"and provide a reproducible example explaining what you were " *
"trying to do."
"$action the attribute `$attr`. If you encountered this error " *
"unexpectedly, it probably means your model has been " *
"reformulated using the bridge, and you are attempting to query " *
"an attribute that we haven't implemented yet for this bridge. " *
"Please open an issue at https://github.com/jump-dev/MathOptInterface.jl/issues/new " *
"and provide a reproducible example explaining what you were " *
"trying to do."
end


Expand Down Expand Up @@ -175,13 +175,13 @@ function MOI.set(
model::MOI.ModelLike,
attr::MOI.AbstractConstraintAttribute,
bridge::AbstractBridge,
_,
::Any,
)
message = _attribute_error_message(attr, bridge, "setting a value for")

Check warning on line 180 in src/Bridges/bridge.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/bridge.jl#L180

Added line #L180 was not covered by tests
if MOI.is_copyable(attr) && !MOI.supports(model, attr, typeof(bridge))
throw(MOI.UnsupportedAttribute(attr, message))
return throw(MOI.UnsupportedAttribute(attr, message))

Check warning on line 182 in src/Bridges/bridge.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/bridge.jl#L182

Added line #L182 was not covered by tests
else
throw(MOI.SetAttributeNotAllowed(attr, message))
return throw(MOI.SetAttributeNotAllowed(attr, message))

Check warning on line 184 in src/Bridges/bridge.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/bridge.jl#L184

Added line #L184 was not covered by tests
end
end

Expand Down
16 changes: 6 additions & 10 deletions test/Bridges/bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ MOI.Utilities.@model(

struct AttributeNotAllowed <: MOI.AbstractConstraintAttribute end

function MOI.supports(::MOI.ModelLike, ::AttributeNotAllowed, ::Type{<:MOI.Bridges.Constraint.SplitIntervalBridge})
function MOI.supports(
::MOI.ModelLike,
::AttributeNotAllowed,
::Type{<:MOI.Bridges.Constraint.SplitIntervalBridge},
)
return true
end

Expand All @@ -237,15 +241,7 @@ function test_unsupported_constraint_attribute()
MOI.LessThan{Float64},
}
attr = MOI.Test.UnknownConstraintAttribute()
message(action) =
"Bridge of type `$(nameof(bridge))` does not support $action " *
"the attribute `$attr`. If you encountered this error " *
"unexpectedly, it probably means your model has been " *
"reformulated using the bridge, and you are attempting to query " *
"an attribute that we haven't implemented yet for this bridge. " *
"Please open an issue at https://github.com/jump-dev/MathOptInterface.jl/issues/new " *
"and provide a reproducible example explaining what you were " *
"trying to do."
message(action) = MOI._attribute_error_message(attr, bridge, action)
x = MOI.add_variable(bridged_mock)
ci = MOI.add_constraint(bridged_mock, x, MOI.Interval(0.0, 1.0))
@test !MOI.Bridges.is_bridged(bridged_mock, ci)
Expand Down

0 comments on commit cc57d09

Please sign in to comment.