From 782341f57a37ecdcdf84499ee06cf2cf8c6cd50e Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 28 May 2018 13:53:50 +0200 Subject: [PATCH 1/7] =?UTF-8?q?Remove=20compat=20for=20function=20composit?= =?UTF-8?q?ion=20and=20negation=20with=20=E2=88=98=20and=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of Julia since 0.6 and the test uses the deprecated `hex` function. --- README.md | 5 ----- src/Compat.jl | 8 -------- test/runtests.jl | 7 ------- 3 files changed, 20 deletions(-) diff --git a/README.md b/README.md index dfcb1b1aa..5e1ecad4b 100644 --- a/README.md +++ b/README.md @@ -167,12 +167,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `transcode` converts between UTF-xx string encodings in Julia 0.5 (as a lightweight alternative to the LegacyStrings package) ([#17323]) -* `∘` (typically used infix as `f ∘ g`) for function composition can be used in 0.5 and earlier ([#17155]) - * `>:`, a supertype operator for symmetry with `issubtype` (`A >: B` is equivalent to `B <: A`), can be used in 0.5 and earlier ([#20407]). -* The method of `!` to negate functions (typically used as a unary operator, as in `!isinteger`) can be used in 0.5 and earlier ([#17155]). - * `iszero(x)` efficiently checks whether `x == zero(x)` (including arrays) can be used in 0.5 and earlier ([#19950]). * `.&` and `.|` are short syntax for `broadcast(&, xs...)` and `broadcast(|, xs...)` (respectively) in Julia 0.6 (only supported on Julia 0.5 and above) ([#17623]) @@ -500,7 +496,6 @@ includes this fix. Find the minimum version from there. [#13681]: https://github.com/JuliaLang/julia/issues/13681 [#16564]: https://github.com/JuliaLang/julia/issues/16564 [#16986]: https://github.com/JuliaLang/julia/issues/16986 -[#17155]: https://github.com/JuliaLang/julia/issues/17155 [#17302]: https://github.com/JuliaLang/julia/issues/17302 [#17323]: https://github.com/JuliaLang/julia/issues/17323 [#17510]: https://github.com/JuliaLang/julia/issues/17510 diff --git a/src/Compat.jl b/src/Compat.jl index 562eacad7..34654620b 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -281,14 +281,6 @@ if VERSION < v"0.6.0-dev.1256" Base.take!(io::Base.AbstractIOBuffer) = takebuf_array(io) end -# julia #17155 function composition and negation -@static if VERSION < v"0.6.0-dev.1883" - export ∘ - ∘(f, g) = (x...)->f(g(x...)) - @compat Base.:!(f::Function) = (x...)->!f(x...) -end - - if VERSION < v"0.6.0-dev.1632" # To work around unsupported syntax on Julia 0.4 include_string("export .&, .|") diff --git a/test/runtests.jl b/test/runtests.jl index d98de0e90..2178b488f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -323,13 +323,6 @@ let s = "Koala test: 🐨" end end -# julia#17155, tests from Base Julia -@test (Compat.Unicode.uppercase∘hex)(239487) == "3A77F" -let str = "aBcDeFgHiJ" - @test filter(!Compat.Unicode.isupper, str) == replace(str, r"[A-Z]" => "") - @test filter(!Compat.Unicode.islower, str) == replace(str, r"[a-z]" => "") -end - # julia#19950, tests from Base (#20028) for T in (Float16, Float32, Float64, BigFloat, Int8, Int16, Int32, Int64, Int128, BigInt, UInt8, UInt16, UInt32, UInt64, UInt128) From 3b33b2d9e5feac828a17424ed0a1d399400d4fa8 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 29 May 2018 08:54:17 +0200 Subject: [PATCH 2/7] Provide and utilize `isbitstype` --- README.md | 3 +++ src/Compat.jl | 6 ++++++ test/runtests.jl | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e1ecad4b..198d549aa 100644 --- a/README.md +++ b/README.md @@ -300,6 +300,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.rmul!` provides a subset of the functionality of `LinearAlgebra.rmul!` for use with Julia 0.6 ([#25701], [#25812]). +* `isbits(t::Type)` is now `isbitstype(t)` ([#26850]). + ## Renaming * `Display` is now `AbstractDisplay` ([#24831]). @@ -630,4 +632,5 @@ includes this fix. Find the minimum version from there. [#26442]: https://github.com/JuliaLang/julia/issues/26442 [#26660]: https://github.com/JuliaLang/julia/issues/26660 [#26670]: https://github.com/JuliaLang/julia/issues/26670 +[#26850]: https://github.com/JuliaLang/julia/issues/26850 [#27077]: https://github.com/JuliaLang/julia/issues/27077 diff --git a/src/Compat.jl b/src/Compat.jl index 34654620b..1ee17e6d8 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1863,6 +1863,12 @@ end const isletter = isalpha end +# https://github.com/JuliaLang/julia/pull/26850 +if !isdefined(Base, :isbitstype) # 0.7.0-DEV.4905 + export isbitstype + isbitstype(::Type{T}) where {T} = isbits(T) +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 2178b488f..76f5ab9b4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -513,7 +513,7 @@ end @test Compat.TypeUtils.isabstract(Abstract20418) @compat primitive type Primitive20418{T} <: Ref{T} 16 end @test !Compat.TypeUtils.isabstract(Primitive20418) -@test isbits(Primitive20418{Int}) +@test isbitstype(Primitive20418{Int}) @test sizeof(Primitive20418{Int}) == 2 # PR #20500 @@ -1725,4 +1725,8 @@ end @test isletter('β') @test !isletter('3') +# 0.7.0-DEV.4905 +@test isbitstype(Int) +@test !isbitstype(Vector{Int}) + nothing From 13ebf765a2aaaf02159b0531bf1f4a71c691b538 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 29 May 2018 14:21:25 +0200 Subject: [PATCH 3/7] Use `diag` instzead of `cholfact` to test definition of `LinearAlgebra` --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 76f5ab9b4..d0ac67be5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1076,8 +1076,8 @@ end @test occursin('W', "Hello, World!") # 0.7.0-DEV.3449 -let A = [2.0 1.0; 1.0 3.0], b = [1.0, 2.0], x = [0.2, 0.6] - @test cholfact(A) \ b ≈ x +let A = [2.0 1.0; 1.0 3.0], b = [2.0, 3.0] + @test diag(A) == b end # 0.7.0-DEV.3173 From b2acd0dadf76c9a5339d25971ff0e63a104ba824 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Wed, 30 May 2018 08:26:27 +0200 Subject: [PATCH 4/7] Consistently use `Compat.Dates` --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index d0ac67be5..31751998f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1113,7 +1113,7 @@ x = Compat.Dates.Second(172799) @test round(x, Compat.Dates.Second) == Compat.Dates.Second(172799) @test round(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) -x = Dates.Nanosecond(2000999999) +x = Compat.Dates.Nanosecond(2000999999) @test floor(x, Compat.Dates.Second) == Compat.Dates.Second(2) @test floor(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2000) @test floor(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2000999) @@ -1144,7 +1144,7 @@ x = Compat.Dates.Hour(36) @test_throws DomainError round(x, Compat.Dates.Day, RoundNearest) @test_throws DomainError round(x, Compat.Dates.Day, RoundNearestTiesAway) @test_throws DomainError round(x, Compat.Dates.Day, RoundToZero) -@test round(x, Dates.Day) == round(x, Compat.Dates.Day, RoundNearestTiesUp) +@test round(x, Compat.Dates.Day) == round(x, Compat.Dates.Day, RoundNearestTiesUp) x = Compat.Dates.Hour(86399) for p in [Compat.Dates.Week, Compat.Dates.Day, Compat.Dates.Hour, Compat.Dates.Second, Compat.Dates.Millisecond, Compat.Dates.Microsecond, Compat.Dates.Nanosecond] From d4e33023ea4ad7e75ba5f2c666594df125177c95 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Wed, 30 May 2018 09:25:36 +0200 Subject: [PATCH 5/7] Use tuples in CartesianIndices and LinearIndices c'tors --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 31751998f..35b440cde 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1165,7 +1165,7 @@ for p in [Compat.Dates.Year, Compat.Dates.Month] end # 0.7.0-DEV.3025 -let c = CartesianIndices(1:3, 1:2), l = LinearIndices(1:3, 1:2) +let c = CartesianIndices((1:3, 1:2)), l = LinearIndices((1:3, 1:2)) @test LinearIndices(c) == collect(l) @test CartesianIndices(l) == collect(c) @test first(c) == CartesianIndex(1, 1) From b47a6e3fc9529c95901ab14b51c49212a306c651 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Wed, 30 May 2018 09:26:40 +0200 Subject: [PATCH 6/7] Fix deprecations due to mixed scalar/broadcast assigment --- test/runtests.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 35b440cde..43ce90267 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -427,7 +427,7 @@ let X = reshape(1:24,2,3,4), Y = 4:-1:1 @test isa(x[1:3],SubArray) @test x[2] === 11 @test Dict((1:3) => 4)[1:3] === 4 - x[1:2] = 0 + x[1:2] .= 0 @test x == [0,0,19,4] x[1:2] .= 5:6 @test x == [5,6,19,4] @@ -435,7 +435,7 @@ let X = reshape(1:24,2,3,4), Y = 4:-1:1 @test x == [5,6,35,4] x[Y[2:3]] .= 7:8 @test x == [5,8,7,4] - @dotcompat x[(3,)..., ()...] += 3 # @. should convert to .+=, test compatibility with @views + @dotcompat x[([3],)..., ()...] += 3 # @. should convert to .+=, test compatibility with @views @test x == [5,8,10,4] i = Int[] # test that lhs expressions in update operations are evaluated only once: @@ -454,7 +454,7 @@ let X = reshape(1:24,2,3,4), Y = 4:-1:1 @test isa(x[1:3],SubArray) @test x[2] === 11 @test Dict((1:3) => 4)[1:3] === 4 - x[1:2] = 0 + x[1:2] .= 0 @test x == [0,0,19,4] x[1:2] .= 5:6 @test x == [5,6,19,4] @@ -462,7 +462,7 @@ let X = reshape(1:24,2,3,4), Y = 4:-1:1 @test x == [5,6,35,4] x[Y[2:3]] .= 7:8 @test x == [5,8,7,4] - @dotcompat x[(3,)..., ()...] += 3 # @. should convert to .+=, test compatibility with @views + @dotcompat x[([3],)..., ()...] += 3 # @. should convert to .+=, test compatibility with @views @test x == [5,8,10,4] i = Int[] # test that lhs expressions in update operations are evaluated only once: From 66e9d375d6b46e4b0847a4a19efa4fe604d92999 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Wed, 30 May 2018 09:43:18 +0200 Subject: [PATCH 7/7] Use at-test_logs to test (and suppress) output from at-dep_verctorize'd methods --- test/runtests.jl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 43ce90267..836fafb7f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -199,19 +199,26 @@ end @test @__DIR__() == dirname(@__FILE__) # PR #17302 -# To be removed when 0.5/0.6 support is dropped. +# To be removed when 0.6 support is dropped. f17302(a::Number) = a f17302(a::Number, b::Number) = a + b Compat.@dep_vectorize_1arg Real f17302 Compat.@dep_vectorize_2arg Real f17302 @test_throws MethodError f17302([1im]) @test_throws MethodError f17302([1im], [1im]) -mktemp() do fname, f - redirect_stderr(f) do - @test f17302([1.0]) == [1.0] - @test f17302(1.0, [1]) == [2.0] - @test f17302([1.0], 1) == [2.0] - @test f17302([1.0], [1]) == [2.0] +@static if VERSION ≥ v"0.7.0-DEV.2988" + @test (@test_logs (:warn, "`f17302(x::(Base.AbstractArray){T}) where T <: Real` is deprecated, use `f17302.(x)` instead.") f17302([1.0])) == [1.0] + @test (@test_logs (:warn, "`f17302(x::Real, y::(Base.AbstractArray){T1}) where T1 <: Real` is deprecated, use `f17302.(x, y)` instead.") f17302(1.0, [1])) == [2.0] + @test (@test_logs (:warn, "`f17302(x::(Base.AbstractArray){T1}, y::Real) where T1 <: Real` is deprecated, use `f17302.(x, y)` instead.") f17302([1.0], 1)) == [2.0] + @test (@test_logs (:warn, "`f17302(x::(Base.AbstractArray){T1}, y::(Base.AbstractArray){T2}) where {T1 <: Real, T2 <: Real}` is deprecated, use `f17302.(x, y)` instead.") f17302([1.0], [1])) == [2.0] +else + mktemp() do fname, f + redirect_stderr(f) do + @test f17302([1.0]) == [1.0] + @test f17302(1.0, [1]) == [2.0] + @test f17302([1.0], 1) == [2.0] + @test f17302([1.0], [1]) == [2.0] + end end end