From 9b971d3f11c0a656a1e8007f87800fc7e66d4d2c Mon Sep 17 00:00:00 2001 From: Jiahao Chen Date: Wed, 11 Nov 2015 23:48:01 -0500 Subject: [PATCH] import deprecated functions from Base On 0.5, the 8 functions excised from Base are still defined, as they have methods that print the error to use Combinatorics.jl. Ref: https://github.com/JuliaLang/julia/pull/13897#issuecomment-155995516 --- src/Combinatorics.jl | 8 ++++++++ test/combinations.jl | 3 --- test/partitions.jl | 1 - test/permutations.jl | 2 -- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Combinatorics.jl b/src/Combinatorics.jl index 44fea2b..0a21da6 100644 --- a/src/Combinatorics.jl +++ b/src/Combinatorics.jl @@ -4,6 +4,14 @@ using Compat, Polynomials, Iterators import Base: start, next, done, length, eltype +#These 8 functions were removed from Julia 0.5 as part of JuliaLang/julia#13897, +#so check if it's necessary to import them to overload the stub methods left in +#Base. +if isdefined(Base, :combinations) + import Base: combinations, partitions, prevprod, levicivita, nthperm, + nthperm!, parity, permutations +end + include("numbers.jl") include("factorials.jl") include("combinations.jl") diff --git a/test/combinations.jl b/test/combinations.jl index cee1e57..51f29e8 100644 --- a/test/combinations.jl +++ b/test/combinations.jl @@ -1,9 +1,6 @@ using Combinatorics using Base.Test -import Combinatorics: combinations - - @test collect(combinations([])) == [] @test collect(combinations(['a', 'b', 'c'])) == Any[['a'],['b'],['c'],['a','b'],['a','c'],['b','c'],['a','b','c']] diff --git a/test/partitions.jl b/test/partitions.jl index a4f79b0..4b03d5f 100644 --- a/test/partitions.jl +++ b/test/partitions.jl @@ -1,6 +1,5 @@ using Combinatorics using Base.Test -import Combinatorics: partitions, prevprod @test collect(partitions(4)) == Any[[4], [3,1], [2,2], [2,1,1], [1,1,1,1]] @test collect(partitions(8,3)) == Any[[6,1,1], [5,2,1], [4,3,1], [4,2,2], [3,3,2]] diff --git a/test/permutations.jl b/test/permutations.jl index eccf1ec..1d1103f 100644 --- a/test/permutations.jl +++ b/test/permutations.jl @@ -1,8 +1,6 @@ using Combinatorics using Base.Test -import Combinatorics: levicivita, nthperm, nthperm!, parity, permutations - # permutations @test collect(permutations("abc")) == Any[['a','b','c'],['a','c','b'],['b','a','c'], ['b','c','a'],['c','a','b'],['c','b','a']]