Skip to content

Commit

Permalink
XLSX/unique fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Nov 2, 2024
1 parent 4bde8bc commit 17b668d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
8 changes: 3 additions & 5 deletions src/MadsHelpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,9 @@ function merge_dictionaries(a::AbstractDict, b::AbstractDict)
return m
end

function nonunique(x::AbstractVector{T}) where T
iu = unique_indices(x::AbstractVector)
iunique = trues(length(x))

return iunique
function nonunique(x::AbstractVector)
iu = nonunique_indices(x)
return x[iu]
end

function nonunique_mask(x::AbstractVector)
Expand Down
6 changes: 5 additions & 1 deletion src/MadsIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Get data from an EXCEL file
$(DocumentFunction.documentfunction(get_excel_data))
"""
function get_excel_data(excel_file::String, sheet_name::String=""; header::Union{Int, Vector{Int}, UnitRange{Int}}=1, rows::Union{Int, Vector{Int}, UnitRange{Int}}=0, cols::Union{Int, Vector{Int}, UnitRange{Int}}=0, keytype::DataType=String, numbertype::DataType=Float64, mapping::Dict=Dict(), dataframe::Bool=true)::Union{OrderedCollections.OrderedDict, DataFrames.DataFrame}
function get_excel_data(excel_file::AbstractString, sheet_name::AbstractString=""; header::Union{Int, Vector{Int}, UnitRange{Int}}=1, rows::Union{Int, Vector{Int}, UnitRange{Int}}=0, cols::Union{Int, Vector{Int}, UnitRange{Int}}=0, keytype::DataType=String, numbertype::DataType=Float64, mapping::Dict=Dict(), dataframe::Bool=true)::Union{OrderedCollections.OrderedDict, DataFrames.DataFrame}
@assert numbertype <: Real
if dataframe
df = DataFrames.DataFrame()
Expand Down Expand Up @@ -124,6 +124,10 @@ function get_excel_data(excel_file::String, sheet_name::String=""; header::Union
p = p == "" ? "Column $c" : p
push!(params, p)
end
ni = Mads.nonunique_indices(params)
for i in ni
params[i] = "$(params[i]) C$(i)"
end
if rows == 0
row_range = (maximum(header) + 1):xf[sheet_name].dimension.stop.row_number
row_vector = collect(row_range)
Expand Down
2 changes: 1 addition & 1 deletion src/MadsTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function test(testname::AbstractString=""; madstest::Bool=true, plotting::Bool=t
else
file = joinpath(d, "test", "$testname.jl")
if isfile(file)
printstyled(:cyan, "* $testname testing ...\n"; color=:cyan)
printstyled("* $testname testing ...\n"; color=:cyan)
@elapsed include(file)
elseif Mads.pkginstalled(testname)
testmodule(testname)
Expand Down
9 changes: 9 additions & 0 deletions test/miscellaneous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,13 @@ Mads.graphon()

deleteat!(ARGS, 1)

@Test.testset "Unique/Nonunique functions" begin
@Test.test Mads.unique_indices([1,2,3,3]) == [1,2,3]
@Test.test Mads.nonunique_indices([1,2,3,3]) == [4]
@Test.test Mads.unique_mask([1,2,3,3]) == [true, true, true, false]
@Test.test Mads.nonunique_mask([1,2,3,3]) == [false, false, false, true]
@Test.test Mads.unique([1,2,3,3]) == [1,2,3]
@Test.test Mads.nonunique([1,2,3,3]) == [3]
end

:passed
11 changes: 3 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ if lowercase(get(ENV, "CI", "false")) == "true"
setup_code = Base.load_path_setup_code()
path = joinpath(@__DIR__, "..", "ci", "before_script.jl")
code = """
$setup_code
include("$(escape_string(path))")
$setup_code
include("$(escape_string(path))")
"""
run(`$(Base.julia_cmd()) -e $code`)
end
Expand All @@ -13,11 +13,6 @@ end
import Mads
import Test

# madstest = "svr"
# file = joinpath(Mads.dir, "examples", madstest, "runtests.jl")
# include(file)
# poop

Mads.veryquieton()
Mads.graphoff()

Expand All @@ -31,7 +26,7 @@ end

@info("Running MADS tests:")

printstyled("* miscellansfdfeous ...\n"; color=:cyan)
printstyled("* miscellaneous ...\n"; color=:cyan)
@elapsed include("miscellaneous.jl")

printstyled("* io ...\n"; color=:cyan)
Expand Down

0 comments on commit 17b668d

Please sign in to comment.