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

drop Julia 0.7 and add testing on 1.1 #1861

Merged
merged 3 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ os:
# - osx # Disable to speed up CI. JuMP has no binary dependency so the result
# with osx and linux should be similar.
julia:
- 0.7
- 1.0
- 1.1
# This is left as an example for the next big version switch.
# matrix:
# allow_failures:
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.7
julia 1.0
MathOptInterface 0.8.1 0.9
ForwardDiff 0.5 0.11
Calculus
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
# - julia_version: 0.7 # Disabled to speed up CI, tested on Linux with Travis
- julia_version: 1.0
# - julia_version: 1.0 # Disabled to speed up CI, tested on Linux with Travis
- julia_version: 1.1

platform:
- x86 # 32-bit
Expand Down
9 changes: 2 additions & 7 deletions src/parse_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

function _try_parse_idx_set(arg::Expr)
# The parsing of `x[i=1]` changed from `i=1; getindex(x, 1)` to
# `getindex(x; i=1)` from Julia v0.7 to Julia v1 so we need `:kw` for
# Julia v1.0 and :(=) for Julia v0.7
# The parsing of `[i=1]` is however still the same way so we need :(=) for
# both
is_julia_v1 = @static (VERSION >= v"1.0-" ? true : false)
if (is_julia_v1 && arg.head === :kw) || arg.head === :(=)
# [i=1] and x[i=1] parse as :(=) and :kw, respectively.
if arg.head === :kw || arg.head === :(=)
@assert length(arg.args) == 2
return true, arg.args[1], arg.args[2]
elseif isexpr(arg, :call) && arg.args[1] === :in
Expand Down
46 changes: 15 additions & 31 deletions test/SparseAxisArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
function sparse_test(d, sum_d, d2, d3, dsqr, d_bads)
sqr(x) = x^2
@testset "Colon indexing" begin
if VERSION < v"0.7-"
@test_throws ArgumentError d[:, 1]
@test_throws ArgumentError d[:a, :]
else
err = ArgumentError("Indexing with `:` is not supported by" *
" Containers.SparseAxisArray")
@test_throws err d[:, 1]
@test_throws err d[:a, :]
end
err = ArgumentError("Indexing with `:` is not supported by" *
" Containers.SparseAxisArray")
@test_throws err d[:, 1]
@test_throws err d[:a, :]
end
@testset "Map" begin
@test d == @inferred map(identity, d)
Expand All @@ -29,30 +24,19 @@
@test d == identity.(d)
@test dsqr == sqr.(d)
@testset "Different array" begin
if VERSION < v"0.7-"
@test_throws ArgumentError [1, 2] .+ d
@test_throws ArgumentError d .* [1, 2]
else
err = ArgumentError("Cannot broadcast" *
" Containers.SparseAxisArray with" *
" another array of different type")
@test_throws err [1, 2] .+ d
@test_throws err d .* [1, 2]
end
err = ArgumentError("Cannot broadcast" *
" Containers.SparseAxisArray with" *
" another array of different type")
@test_throws err [1, 2] .+ d
@test_throws err d .* [1, 2]
end
@testset "Different indices" begin
if VERSION < v"0.7-"
for d_bad in d_bads
@test_throws ArgumentError d_bad .+ d
@test_throws ArgumentError d .+ d_bad
end
else
err = ArgumentError("Cannot broadcast" *
" Containers.SparseAxisArray with different indices")
for d_bad in d_bads
@test_throws err d_bad .+ d
@test_throws err d .+ d_bad
end
err = ArgumentError("Cannot broadcast" *
" Containers.SparseAxisArray with " *
"different indices")
for d_bad in d_bads
@test_throws err d_bad .+ d
@test_throws err d .+ d_bad
end
end
end
Expand Down
26 changes: 9 additions & 17 deletions test/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ end
@test ex.head == :typed_vcat
@test ex.args == [:x, 12, 3]

if VERSION >= v"1.0-"
ex = :(x[i=1:3, j=S; isodd(i) && i + j >= 2])
@test ex.head == :ref
@test ex.args == [:x,
Expr(:parameters, Expr(:&&, :(isodd(i)), :(i + j >= 2))),
Expr(:kw, :i, :(1:3)),
Expr(:kw, :j, :S)]
end
ex = :(x[i=1:3, j=S; isodd(i) && i + j >= 2])
@test ex.head == :ref
@test ex.args == [:x,
Expr(:parameters, Expr(:&&, :(isodd(i)), :(i + j >= 2))),
Expr(:kw, :i, :(1:3)),
Expr(:kw, :j, :S)]
end

mutable struct MyVariable
Expand Down Expand Up @@ -298,15 +296,9 @@ end
@testset "Warn on unexpected assignment" begin
m = Model()
@variable(m, x)
@static if VERSION >= v"1.0"
# function getindex does not accept keyword arguments
@test_throws ErrorException x[i=1]
@test_throws ErrorException @constraint(m, x[i=1] <= 1)
else
# https://github.com/JuliaLang/julia/issues/25612
@test_logs((:warn, r"Unexpected assignment"),
macroexpand(JuMP, :(@constraint(m, x[i=1] <= 1))))
end
# function getindex does not accept keyword arguments
@test_throws ErrorException x[i=1]
@test_throws ErrorException @constraint(m, x[i=1] <= 1)
end

@testset "Lookup in model scope: @variable" begin
Expand Down
5 changes: 1 addition & 4 deletions test/perf/speed2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ include("../solvers.jl")

using JuMP
using Random
@static if VERSION >= v"0.7.0-DEV.3406"
srand(seed) = Random.seed!(seed)
end

function pMedian(solver, numFacility::Int,numCustomer::Int,numLocation::Int)
srand(10)
Random.seed!(10)
customerLocations = [rand(1:numLocation) for a = 1:numCustomer ]

buildTime = @elasped begin
Expand Down
2 changes: 1 addition & 1 deletion test/perf/timetoprint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test4_time = @elapsed begin
@variable(m, x5[[:a,:b,:c],[:d,"e",4]])
@constraint(m,
sum(i*x1[i] for i=1:N) +
sum(i*f*x2[i,f] for i=1:N,f=1:N) +
sum(i*f*x2[i,f] for i=1:N,f=1:N) +
sum(i*f*x3[i,f] for i=1:N,f=1:2:N) +
sum(x4) >= N)
@time sprint(print, m)"""
Expand Down