Skip to content

Commit

Permalink
Fix tests on win32
Browse files Browse the repository at this point in the history
  • Loading branch information
Samayel committed Sep 14, 2015
1 parent 69a31e7 commit 3899594
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 50 deletions.
6 changes: 3 additions & 3 deletions src/Math/Combinatorics/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export

# Multinomial coefficient where n = sum(k)
# https://github.com/jiahao/Combinatorics.jl/blob/master/src/Combinatorics.jl
multinomial(k...) = begin
s = 0
result = 1
multinomial{T<:Integer}(k::AbstractArray{T,1}) = begin
s = zero(T)
result = one(T)
for i in k
s += i
result *= binomial(s, i)
Expand Down
12 changes: 6 additions & 6 deletions src/Math/Combinatorics/multicombination.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Base.combinations{T,U<:Integer}(a::AbstractArray{T,1}, c::AbstractArray{U,1}, k::Integer) =
MultisetCombinations(a, c, k)
Base.combinations{T,U<:Integer}(a::AbstractArray{T,1}, c::AbstractArray{U,1}, k::U) =
MultisetCombinations{T,U}(a, c, k)

immutable MultisetCombinations{T,U}
a::T
c::U
k::Int
a::AbstractArray{T,1}
c::AbstractArray{U,1}
k::U
end

Base.start(c::MultisetCombinations) = begin
Expand Down Expand Up @@ -41,7 +41,7 @@ end
Base.done(c::MultisetCombinations, s) = !isempty(s) && s[1] > length(c.a)

Base.eltype(c::MultisetCombinations) = eltype(typeof(c))
Base.eltype{T,U}(::Type{MultisetCombinations{T,U}}) = Array{eltype(T),1}
Base.eltype{T,U}(::Type{MultisetCombinations{T,U}}) = Array{T,1}

Base.length(c::MultisetCombinations) = begin
c.k == 0 && return 1
Expand Down
14 changes: 7 additions & 7 deletions src/Math/Combinatorics/multipermutation.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

Base.permutations{T,U<:Integer}(a::AbstractArray{T,1}, c::AbstractArray{U,1}) =
permutations(a, c, sum(c))
Base.permutations{T,U<:Integer}(a::AbstractArray{T,1}, c::AbstractArray{U,1}, k::Integer) =
MultisetPermuations(a, c, k)
Base.permutations{T,U<:Integer}(a::AbstractArray{T,1}, c::AbstractArray{U,1}, k::U) =
MultisetPermuations{T,U}(a, c, k)

immutable MultisetPermuations{T,U}
a::T
c::U
k::Int
a::AbstractArray{T,1}
c::AbstractArray{U,1}
k::U
end

Base.start(p::MultisetPermuations) = begin
Expand Down Expand Up @@ -39,14 +39,14 @@ end
Base.done(p::MultisetPermuations, s) = !isempty(s) && s[1] > length(p.a)

Base.eltype(p::MultisetPermuations) = eltype(typeof(p))
Base.eltype{T,U}(::Type{MultisetPermuations{T,U}}) = Array{eltype(T),1}
Base.eltype{T,U}(::Type{MultisetPermuations{T,U}}) = Array{T,1}

Base.length(p::MultisetPermuations) = begin
p.k == 0 && return 1

csum = sum(p.c)
p.k > csum && return 0
p.k == csum && return multinomial(p.c...)
p.k == csum && return multinomial(p.c)

s = expand_maclaurin_series(GFPerm(p.c), p.k, Number)
round(Int, factorial(p.k) * coefficient(s, p.k))
Expand Down
16 changes: 8 additions & 8 deletions test/Math/Combinatorics/combination.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function test_combination_combinations()
@test collect(combinations(Int[], 0, Val{:unique}())) == Array{Int64,1}[[]]
@test collect(combinations(Int[], 0, Val{:unique}())) == Array{Int,1}[[]]
@test length(combinations(Int[], 0, Val{:unique}())) == 1
@test eltype(combinations(Int[], 0, Val{:unique}())) == Array{Int64,1}
@test eltype(combinations(Int[], 0, Val{:unique}())) == Array{Int,1}

@test collect(combinations(Int[], 1, Val{:unique}())) == Array{Int64,1}[]
@test collect(combinations(Int[], 1, Val{:unique}())) == Array{Int,1}[]
@test length(combinations(Int[], 1, Val{:unique}())) == 0
@test eltype(combinations(Int[], 1, Val{:unique}())) == Array{Int64,1}
@test eltype(combinations(Int[], 1, Val{:unique}())) == Array{Int,1}

@test collect(combinations(["a", "b", "c", "d"], 2, Val{:unique}())) == Array[
["a", "b"],
Expand All @@ -23,13 +23,13 @@ function test_combination_combinations()
end

function test_combination_combinations_with_repetition()
@test collect(combinations(Int[], 0, Val{:repeated}())) == Array{Int64,1}[[]]
@test collect(combinations(Int[], 0, Val{:repeated}())) == Array{Int,1}[[]]
@test length(combinations(Int[], 0, Val{:repeated}())) == 1
@test eltype(combinations(Int[], 0, Val{:repeated}())) == Array{Int64,1}
@test eltype(combinations(Int[], 0, Val{:repeated}())) == Array{Int,1}

@test collect(combinations(Int[], 1, Val{:repeated}())) == Array{Int64,1}[]
@test collect(combinations(Int[], 1, Val{:repeated}())) == Array{Int,1}[]
@test length(combinations(Int[], 1, Val{:repeated}())) == 0
@test eltype(combinations(Int[], 1, Val{:repeated}())) == Array{Int64,1}
@test eltype(combinations(Int[], 1, Val{:repeated}())) == Array{Int,1}

@test collect(combinations(["a", "b", "c", "d"], 2, Val{:repeated}())) == Array[
["a", "a"],
Expand Down
8 changes: 4 additions & 4 deletions test/Math/Combinatorics/multicombination.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function test_multicombination_combinations()
@test collect(combinations(Int[], Int[], 0)) == Array{Int64,1}[[]]
@test collect(combinations(Int[], Int[], 0)) == Array{Int,1}[[]]
@test length(combinations(Int[], Int[], 0)) == 1
@test eltype(combinations(Int[], Int[], 0)) == Array{Int64,1}
@test eltype(combinations(Int[], Int[], 0)) == Array{Int,1}

@test collect(combinations(Int[], Int[], 1)) == Array{Int64,1}[]
@test collect(combinations(Int[], Int[], 1)) == Array{Int,1}[]
@test length(combinations(Int[], Int[], 1)) == 0
@test eltype(combinations(Int[], Int[], 1)) == Array{Int64,1}
@test eltype(combinations(Int[], Int[], 1)) == Array{Int,1}

@test collect(combinations(["a", "b"], [2, 1], 3)) == Array[
["a", "a", "b"],
Expand Down
14 changes: 7 additions & 7 deletions test/Math/Combinatorics/multipermutation.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function test_multipermutation_permutations()
@test collect(permutations(Int[], Int[])) == Array{Int64,1}[[]]
@test collect(permutations(Int[], Int[])) == Array{Int,1}[[]]
@test length(permutations(Int[], Int[])) == 1
@test eltype(permutations(Int[], Int[])) == Array{Int64,1}
@test eltype(permutations(Int[], Int[])) == Array{Int,1}

@test collect(permutations(["a", "b"], [2, 1])) == Array[
["a", "a", "b"],
Expand All @@ -12,15 +12,15 @@ function test_multipermutation_permutations()
@test eltype(permutations(["a", "b"], [2, 1])) == Array{ASCIIString,1}

@test length(permutations(["M","I","S","P"], [1,4,4,2])) == 34650
@test length(permutations([:right,:down], [20,20])) == 137846528820
@test length(permutations([:right,:down], BigInt[20,20])) == 137846528820

@test collect(permutations(Int[], Int[], 0)) == Array{Int64,1}[[]]
@test collect(permutations(Int[], Int[], 0)) == Array{Int,1}[[]]
@test length(permutations(Int[], Int[], 0)) == 1
@test eltype(permutations(Int[], Int[], 0)) == Array{Int64,1}
@test eltype(permutations(Int[], Int[], 0)) == Array{Int,1}

@test collect(permutations(Int[], Int[], 1)) == Array{Int64,1}[]
@test collect(permutations(Int[], Int[], 1)) == Array{Int,1}[]
@test length(permutations(Int[], Int[], 1)) == 0
@test eltype(permutations(Int[], Int[], 1)) == Array{Int64,1}
@test eltype(permutations(Int[], Int[], 1)) == Array{Int,1}

@test collect(permutations(["a", "b"], [3, 2], 3)) == Array[
["a", "a", "a"],
Expand Down
24 changes: 12 additions & 12 deletions test/Math/Combinatorics/permutation.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function test_permutation_permutations()
@test collect(permutations(Int[], Val{:unique}())) == Array{Int64,1}[[]]
@test collect(permutations(Int[], Val{:unique}())) == Array{Int,1}[[]]
@test length(permutations(Int[], Val{:unique}())) == 1
@test eltype(permutations(Int[], Val{:unique}())) == Array{Int64,1}
@test eltype(permutations(Int[], Val{:unique}())) == Array{Int,1}

@test collect(permutations(["a", "b", "c"], Val{:unique}())) == Array[
["a", "b", "c"],
Expand All @@ -16,9 +16,9 @@ function test_permutation_permutations()
end

function test_permutation_permutations_with_repetition()
@test collect(permutations(Int[], Val{:repeated}())) == Array{Int64,1}[[]]
@test collect(permutations(Int[], Val{:repeated}())) == Array{Int,1}[[]]
@test length(permutations(Int[], Val{:repeated}())) == 1
@test eltype(permutations(Int[], Val{:repeated}())) == Array{Int64,1}
@test eltype(permutations(Int[], Val{:repeated}())) == Array{Int,1}

@test collect(permutations(["a", "b", "c"], Val{:repeated}())) == Array[
["a", "a", "a"],
Expand Down Expand Up @@ -58,13 +58,13 @@ function test_permutation_permutations_unknown_mode()
end

function test_permutation_kpermutations()
@test collect(permutations(Int[], 0, Val{:unique}())) == Array{Int64,1}[[]]
@test collect(permutations(Int[], 0, Val{:unique}())) == Array{Int,1}[[]]
@test length(permutations(Int[], 0, Val{:unique}())) == 1
@test eltype(permutations(Int[], 0, Val{:unique}())) == Array{Int64,1}
@test eltype(permutations(Int[], 0, Val{:unique}())) == Array{Int,1}

@test collect(permutations(Int[], 1, Val{:unique}())) == Array{Int64,1}[]
@test collect(permutations(Int[], 1, Val{:unique}())) == Array{Int,1}[]
@test length(permutations(Int[], 1, Val{:unique}())) == 0
@test eltype(permutations(Int[], 1, Val{:unique}())) == Array{Int64,1}
@test eltype(permutations(Int[], 1, Val{:unique}())) == Array{Int,1}

@test collect(permutations(["a", "b", "c", "d"], 2, Val{:unique}())) == Array[
["a", "b"],
Expand Down Expand Up @@ -117,13 +117,13 @@ function test_permutation_kpermutations()
end

function test_permutation_kpermutations_with_repetition()
@test collect(permutations(Int[], 0, Val{:repeated}())) == Array{Int64,1}[[]]
@test collect(permutations(Int[], 0, Val{:repeated}())) == Array{Int,1}[[]]
@test length(permutations(Int[], 0, Val{:repeated}())) == 1
@test eltype(permutations(Int[], 0, Val{:repeated}())) == Array{Int64,1}
@test eltype(permutations(Int[], 0, Val{:repeated}())) == Array{Int,1}

@test collect(permutations(Int[], 1, Val{:repeated}())) == Array{Int64,1}[]
@test collect(permutations(Int[], 1, Val{:repeated}())) == Array{Int,1}[]
@test length(permutations(Int[], 1, Val{:repeated}())) == 0
@test eltype(permutations(Int[], 1, Val{:repeated}())) == Array{Int64,1}
@test eltype(permutations(Int[], 1, Val{:repeated}())) == Array{Int,1}

@test collect(permutations(["a", "b", "c", "d"], 2, Val{:repeated}())) == Array[
["a", "a"],
Expand Down
2 changes: 1 addition & 1 deletion test/Math/NumberTheory/Primes/native.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Base.Test

function test_factorization()
@test factorization(147573952589676412927) ==
Dict{Int,Int}(193707721 => 1, 761838257287 => 1)
Dict{Int64,Int}(193707721 => 1, 761838257287 => 1)
@test factorization((big(2)^31-1)*(big(2)^17-1)) ==
Dict(big(2^31-1) => 1, big(2^17-1) => 1)
end
Expand Down
2 changes: 1 addition & 1 deletion test/Math/NumberTheory/diophantine_quadratic.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function test_diophantine_solve_diophantine_quadratic()
soltype = Array{AbstractDiophantineSolutions{DiophantineSolutionXY{Int64}},1}
soltype = Array{AbstractDiophantineSolutions{DiophantineSolutionXY{Int}},1}

# linear
sol = solve(diophantine_equation_quadratic_xy(cx=3, c0=-9))
Expand Down
2 changes: 1 addition & 1 deletion test/Math/NumberTheory/primes.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function test_primes_factorization()
@test factorization(147573952589676412927) ==
Dict{Int,Int}(193707721 => 1, 761838257287 => 1)
Dict{Int64,Int}(193707721 => 1, 761838257287 => 1)
@test factorization((big(2)^31-1)*(big(2)^17-1)) ==
Dict(big(2^31-1) => 1, big(2^17-1) => 1)
fastprimes() && @test factorization((big(2)^31-1)^2) ==
Expand Down

0 comments on commit 3899594

Please sign in to comment.