Skip to content
Permalink
Browse files

drop Julia 0.7 and add testing on 1.1 (#1861)

* drop Julia 0.7 and add testing on 1.1

* drop dead code

* expand on comment
  • Loading branch information...
mlubin committed Feb 14, 2019
1 parent 22c9309 commit 6ee9ed0cd25ad39b93127a6ca09c1fbe94aa5201
Showing with 33 additions and 64 deletions.
  1. +1 −1 .travis.yml
  2. +1 −1 REQUIRE
  3. +2 −2 appveyor.yml
  4. +3 −7 src/parse_expr.jl
  5. +15 −31 test/SparseAxisArray.jl
  6. +9 −17 test/macros.jl
  7. +1 −4 test/perf/speed2.jl
  8. +1 −1 test/perf/timetoprint.jl
@@ -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:
@@ -1,4 +1,4 @@
julia 0.7
julia 1.0
MathOptInterface 0.8.1 0.9
ForwardDiff 0.5 0.11
Calculus
@@ -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
@@ -4,13 +4,9 @@
# 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 Expr(:vect, Expr(:(=), :i, 1)) and
# Expr(:ref, :x, Expr(:kw, :i, 1)) 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
@@ -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)
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)"""

0 comments on commit 6ee9ed0

Please sign in to comment.
You can’t perform that action at this time.