Skip to content

Commit 8f26202

Browse files
authored
Remove VERSION checks for unsupported Julia versions (#3172)
1 parent 6c2b3e1 commit 8f26202

File tree

3 files changed

+31
-32
lines changed

3 files changed

+31
-32
lines changed

src/Containers/SparseAxisArray.jl

+21-23
Original file line numberDiff line numberDiff line change
@@ -288,29 +288,27 @@ function _getindex(
288288
return bc.f(_get_arg(bc.args, index)...)
289289
end
290290

291-
@static if VERSION >= v"1.3"
292-
# `broadcast_preserving_zero_d` calls `axes(A)` which calls `size(A)` which
293-
# is not defined. When at least one argument is a `SparseAxisArray`, we can
294-
# simply redirect `broadcast_preserving_zero_d` to `broadcast` since we know
295-
# the result won't be zero dimensional.
296-
297-
# Called by `A * 2`
298-
function Base.Broadcast.broadcast_preserving_zero_d(
299-
f,
300-
A::SparseAxisArray,
301-
As...,
302-
)
303-
return broadcast(f, A, As...)
304-
end
305-
# Called by `2 * A`
306-
function Base.Broadcast.broadcast_preserving_zero_d(
307-
f,
308-
x,
309-
A::SparseAxisArray,
310-
As...,
311-
)
312-
return broadcast(f, x, A, As...)
313-
end
291+
# `broadcast_preserving_zero_d` calls `axes(A)` which calls `size(A)` which
292+
# is not defined. When at least one argument is a `SparseAxisArray`, we can
293+
# simply redirect `broadcast_preserving_zero_d` to `broadcast` since we know
294+
# the result won't be zero dimensional.
295+
296+
# Called by `A * 2`
297+
function Base.Broadcast.broadcast_preserving_zero_d(
298+
f,
299+
A::SparseAxisArray,
300+
As...,
301+
)
302+
return broadcast(f, A, As...)
303+
end
304+
# Called by `2 * A`
305+
function Base.Broadcast.broadcast_preserving_zero_d(
306+
f,
307+
x,
308+
A::SparseAxisArray,
309+
As...,
310+
)
311+
return broadcast(f, x, A, As...)
314312
end
315313

316314
########

test/test_constraint.jl

+8-6
Original file line numberDiff line numberDiff line change
@@ -691,22 +691,24 @@ function test_extension_nonsensical_SDP_constraint(
691691
"for symmetric variable.",
692692
)
693693
end
694-
# Hack to work around an annoying change in Julia expression printing.
695-
index_set = VERSION < v"1.1" ? "i=1:2, j=1:2" : "i = 1:2, j = 1:2"
696694
@test_throws_strip(
697-
_ErrorException("@variable(m, foo[$index_set] >= Y[i, j], PSD)"),
695+
_ErrorException("@variable(m, foo[i = 1:2, j = 1:2] >= Y[i, j], PSD)"),
698696
@variable(m, foo[i = 1:2, j = 1:2] >= Y[i, j], PSD),
699697
)
700698
@test_throws_strip(
701-
_ErrorException("@variable(m, foo[$index_set] <= Y[i, j], PSD)"),
699+
_ErrorException("@variable(m, foo[i = 1:2, j = 1:2] <= Y[i, j], PSD)"),
702700
@variable(m, foo[i = 1:2, j = 1:2] <= Y[i, j], PSD),
703701
)
704702
@test_throws_strip(
705-
_ErrorException("@variable(m, foo[$index_set] >= Y[i, j], Symmetric)"),
703+
_ErrorException(
704+
"@variable(m, foo[i = 1:2, j = 1:2] >= Y[i, j], Symmetric)",
705+
),
706706
@variable(m, foo[i = 1:2, j = 1:2] >= Y[i, j], Symmetric),
707707
)
708708
@test_throws_strip(
709-
_ErrorException("@variable(m, foo[$index_set] <= Y[i, j], Symmetric)"),
709+
_ErrorException(
710+
"@variable(m, foo[i = 1:2, j = 1:2] <= Y[i, j], Symmetric)",
711+
),
710712
@variable(m, foo[i = 1:2, j = 1:2] <= Y[i, j], Symmetric),
711713
)
712714
return

test/test_macros.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,9 @@ end
957957
function test_Model_as_index()
958958
m = Model()
959959
@variable(m, x)
960-
index_set = VERSION < v"1.1" ? "m=1:2" : "m = 1:2"
961960
msg = "Index m is the same symbol as the model. Use a different name for the index."
962961
@test_macro_throws(
963-
ErrorException("In `@variable(m, y[$(index_set)] <= m)`: $(msg)"),
962+
ErrorException("In `@variable(m, y[m = 1:2] <= m)`: $(msg)"),
964963
@variable(m, y[m = 1:2] <= m),
965964
)
966965
@test_macro_throws(
@@ -982,7 +981,7 @@ function test_Model_as_index()
982981
@NLexpression(m, [m = 1:2], x),
983982
)
984983
@test_macro_throws(
985-
ErrorException("In `@NLparameter(m, p[$(index_set)] == m)`: $(msg)"),
984+
ErrorException("In `@NLparameter(m, p[m = 1:2] == m)`: $(msg)"),
986985
@NLparameter(m, p[m = 1:2] == m),
987986
)
988987
return

0 commit comments

Comments
 (0)