From 58f434991cfc79ebcba52864ea9acb16e9b62f60 Mon Sep 17 00:00:00 2001 From: jbytecode Date: Tue, 21 May 2024 09:34:10 +0300 Subject: [PATCH] fixed type-inf in johnson's rule --- CHANGELOG.md | 2 ++ src/johnsons.jl | 5 ++++- test/testjohnsons.jl | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e34559..4e39cbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ### 0.2.1 (Upcoming Release) +- Typed Inf used instead of Inf64 in Johnson's rule. + ### 0.2.1 diff --git a/src/johnsons.jl b/src/johnsons.jl index cfa3a72..4e1f1df 100644 --- a/src/johnsons.jl +++ b/src/johnsons.jl @@ -92,6 +92,9 @@ function johnsons_2machines(timesmatrix::Matrix)::JohnsonResult times = copy(timesmatrix) n, m = size(times) @assert m == 2 + + typed_inf = typemax(eltype(times)) + permutation = [-1 for i in 1:n] for i in 1:n locrow, loccol = argmin(times).I @@ -100,7 +103,7 @@ function johnsons_2machines(timesmatrix::Matrix)::JohnsonResult else dolast!(locrow, permutation) end - times[locrow, :] .= Inf + times[locrow, :] .= typed_inf end return JohnsonResult(permutation) end diff --git a/test/testjohnsons.jl b/test/testjohnsons.jl index 9a55a07..aa40479 100644 --- a/test/testjohnsons.jl +++ b/test/testjohnsons.jl @@ -85,5 +85,24 @@ end + @testset "Other types of matrices (Int)" begin + + mat = rand(1:10, 10, 2) + + result = johnsons(mat) + + # expect no error + @test true + end + + @testset "Other types of matrices (UInt8)" begin + + mat = convert(Array{UInt8, 2}, rand(1:10, 10, 2)) + + result = johnsons(mat) + + # expect no error + @test true + end end \ No newline at end of file