Skip to content

Commit

Permalink
remove whitespaces from df colnames
Browse files Browse the repository at this point in the history
  • Loading branch information
ivborissov committed Dec 12, 2023
1 parent cd818a0 commit acf9556
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/measurements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function read_measurements(filepath::String, sheet=1; kwargs...)
else
error("Extension $ext is not supported.")
end
return df
return sanitizenames!(df)
end

function assert_measurements(df)
Expand Down
2 changes: 1 addition & 1 deletion src/monte_carlo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,4 @@ Arguments:
- `filepath`: path to the file with pre-generated parameters
"""
read_mcvecs(filepath::String) = DataFrame(CSV.File(filepath; typemap=Dict(Int => Float64)))
read_mcvecs(filepath::String) = sanitizenames!(DataFrame(CSV.File(filepath; typemap=Dict(Int => Float64))))
2 changes: 1 addition & 1 deletion src/scenario.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function read_scenarios(filepath::String, sheet=1; kwargs...)
else
error("Extension $ext is not supported.")
end
return df
return sanitizenames!(df)
end

function assert_scenarios(df)
Expand Down
4 changes: 3 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,6 @@ function bool(s::AbstractString)
s == "FALSE" && return false
return parse(Bool, s)
end
bool(b::Bool) = b
bool(b::Bool) = b

sanitizenames!(df::DataFrame) = rename!(df, strip.(names(df)))
2 changes: 1 addition & 1 deletion test/examples/single_comp/scenarios_table.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
id,parameters.k1,saveat[],tspan
id,parameters.k1, saveat[],tspan
scn3,0.017,12;17;30:10:50;60:20:120,150
3 changes: 2 additions & 1 deletion test/single_comp_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ cs3 = sim(scenarios(platform)[:scn3])
@test length(parameters(cs1))==0
@test parameters(last(cs2[:one]))[:k1] == 0.03
@test parameters(scenarios(platform)[:scn3])[:k1] == 0.017
@test times(cs3) == [12.,17.,30.,40.,50.,60.,80.,100.,120.]
# tests both saveat times and sanitize whitespaces in colnames
@test times(cs3) == [12.,17.,30.,40.,50.,60.,80.,100.,120.]

# Monte-Carlo simulation tests
mciter = 100
Expand Down

0 comments on commit acf9556

Please sign in to comment.