Skip to content

Commit 2fc360d

Browse files
committed
Update SolverBenchmark for DataFrames v0.21
1 parent 4aad12f commit 2fc360d

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1616
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
1717
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1818
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
19+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1920

2021
[compat]
2122
BenchmarkProfiles = "0.2.0, 0.3.0"
2223
BenchmarkTools = "^0.4.2, 0.5"
23-
DataFrames = "^0.20"
24+
DataFrames = "^0.21"
2425
GitHub = "^5.0.2"
2526
JSON = "0.20.0, 0.21.0"
2627
LaTeXTabulars = "^0.1.0"
@@ -37,6 +38,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
3738
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3839
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3940
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
41+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
4042

4143
[targets]
42-
test = ["LibGit2", "LinearAlgebra", "Test", "Plots", "Random", "Printf", "UnicodePlots"]
44+
test = ["LibGit2", "LinearAlgebra", "Test", "Plots", "Random", "Printf", "UnicodePlots", "SparseArrays"]

src/formatting.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ Outputs:
3131
- `table::Array{String,2}`: formatted table.
3232
"""
3333
function format_table(df :: DataFrame, formatter::Function;
34-
cols :: Array{Symbol,1} = names(df),
34+
cols :: Array{Symbol,1} = propertynames(df),
3535
ignore_missing_cols :: Bool = false,
3636
fmt_override :: Dict{Symbol,F} = Dict{Symbol,Function}(),
3737
hdr_override :: Dict{Symbol,String} = Dict{Symbol,String}(),
3838
) where F <: Function
3939
if ignore_missing_cols
4040
cols = filter(c->hasproperty(df, c), cols)
4141
elseif !all(hasproperty(df, c) for c in cols)
42-
missing_cols = setdiff(cols, names(df))
42+
missing_cols = setdiff(cols, propertynames(df))
4343
@error("There are no columns `" * join(missing_cols, ", ") * "` in dataframe")
4444
throw(BoundsError)
4545
end

src/join.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ function join(stats::Dict{Symbol,DataFrame},
2626
hdr_override::Dict{Symbol,String} = Dict{Symbol,String}(),
2727
)
2828
length(cols) == 0 && error("cols can't be empty")
29-
if !all(:id in names(df) for (s,df) in stats)
29+
if !all(:id in propertynames(df) for (s,df) in stats)
3030
error("Missing column :id in some DataFrame")
31-
elseif !all(setdiff(cols, names(df)) == [] for (s,df) in stats)
31+
elseif !all(setdiff(cols, propertynames(df)) == [] for (s,df) in stats)
3232
error("Not all DataFrames have all columns given by `cols`")
3333
end
3434

@@ -49,13 +49,14 @@ function join(stats::Dict{Symbol,DataFrame},
4949
df = stats[s][:, invariant_cols]
5050

5151
rename_f(c, s) = begin
52-
c in invariant_cols && return c
53-
sc = haskey(hdr_override, c) ? hdr_override[c] : string(c)
52+
Symbol(c) in invariant_cols && return c
53+
sc = haskey(hdr_override, c) ? hdr_override[c] : c
5454
Symbol(sc * "_$s")
5555
end
5656

57+
show(df)
5758
for (s, dfs) in stats
58-
df = join(df, rename(c->rename_f(c, s), dfs[!, cols]), on=:id, makeunique=true)
59+
df = innerjoin(df, rename(c->rename_f(c, s), dfs[!, cols]), on=:id, makeunique=true)
5960
end
6061

6162
return df

test/example/joined.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
| id | name | flag_alpha | f_alpha | t_alpha | flag_beta | f_beta | t_beta | flag_gamma | f_gamma | t_gamma |
2-
|-------|---------|------------|----------|----------|-----------|----------|----------|------------|----------|----------|
3-
| 1 | prob001 | failure | -6.9e-01 | 6.2e+01 | success | -1.1e+00 | 1.8e+02 | success | 6.3e-02 | 3.3e+01 |
4-
| 2 | prob002 | failure | -7.6e-01 | 3.5e+02 | failure | 8.2e-01 | 8.0e+01 | success | 1.2e-01 | 6.9e+02 |
5-
| 3 | prob003 | success | 4.0e-01 | 7.7e+02 | success | 1.5e-01 | 6.8e+02 | success | 2.7e+00 | 8.4e+02 |
6-
| 4 | prob004 | success | 8.1e-01 | 4.3e+01 | failure | -3.3e-01 | 9.3e+02 | failure | -6.9e-01 | 1.9e+02 |
7-
| 5 | prob005 | success | -3.5e-01 | 2.7e+02 | failure | 1.4e+00 | 9.7e+02 | failure | -5.5e-02 | 1.6e+02 |
8-
| 6 | prob006 | success | -1.9e-01 | 6.7e+01 | success | -4.4e-01 | 6.5e+02 | success | 4.2e-01 | 9.0e+02 |
9-
| 7 | prob007 | success | -1.6e+00 | 1.6e+02 | success | 1.1e+00 | 6.0e+02 | success | -1.4e+00 | 9.5e+01 |
10-
| 8 | prob008 | success | -2.5e+00 | 6.1e+02 | success | -2.5e-01 | 4.8e+02 | failure | -4.5e-01 | 7.8e+02 |
11-
| 9 | prob009 | success | 2.3e+00 | 1.4e+02 | failure | 2.9e-01 | 6.3e+01 | failure | -8.8e-01 | 8.7e+02 |
12-
| 10 | prob010 | failure | 2.2e-01 | 8.4e+02 | success | -3.5e+00 | 4.7e+02 | success | 1.1e+00 | 8.4e+02 |
1+
| id | name | status_alpha | f_alpha | t_alpha | status_beta | f_beta | t_beta | status_gamma | f_gamma | t_gamma |
2+
|-------|---------|--------------|----------|----------|-------------|----------|----------|--------------|----------|----------|
3+
| 1 | prob001 | failure | -6.9e-01 | 6.2e+01 | success | -1.1e+00 | 1.8e+02 | success | 6.3e-02 | 3.3e+01 |
4+
| 2 | prob002 | failure | -7.6e-01 | 3.5e+02 | failure | 8.2e-01 | 8.0e+01 | success | 1.2e-01 | 6.9e+02 |
5+
| 3 | prob003 | success | 4.0e-01 | 7.7e+02 | success | 1.5e-01 | 6.8e+02 | success | 2.7e+00 | 8.4e+02 |
6+
| 4 | prob004 | success | 8.1e-01 | 4.3e+01 | failure | -3.3e-01 | 9.3e+02 | failure | -6.9e-01 | 1.9e+02 |
7+
| 5 | prob005 | success | -3.5e-01 | 2.7e+02 | failure | 1.4e+00 | 9.7e+02 | failure | -5.5e-02 | 1.6e+02 |
8+
| 6 | prob006 | success | -1.9e-01 | 6.7e+01 | success | -4.4e-01 | 6.5e+02 | success | 4.2e-01 | 9.0e+02 |
9+
| 7 | prob007 | success | -1.6e+00 | 1.6e+02 | success | 1.1e+00 | 6.0e+02 | success | -1.4e+00 | 9.5e+01 |
10+
| 8 | prob008 | success | -2.5e+00 | 6.1e+02 | success | -2.5e-01 | 4.8e+02 | failure | -4.5e-01 | 7.8e+02 |
11+
| 9 | prob009 | success | 2.3e+00 | 1.4e+02 | failure | 2.9e-01 | 6.3e+01 | failure | -8.8e-01 | 8.7e+02 |
12+
| 10 | prob010 | failure | 2.2e-01 | 8.4e+02 | success | -3.5e+00 | 4.7e+02 | success | 1.1e+00 | 8.4e+02 |

test/example/joined.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
\begin{longtable}[c]{lrrrrrrrrrr}
22
\hline
3-
id & name & flag\_alpha & f\_alpha & t\_alpha & flag\_beta & f\_beta & t\_beta & flag\_gamma & f\_gamma & t\_gamma \\
3+
id & name & status\_alpha & f\_alpha & t\_alpha & status\_beta & f\_beta & t\_beta & status\_gamma & f\_gamma & t\_gamma \\
44
\hline
55
\endfirsthead
66
\multicolumn{11}{l}
77
{{\bfseries \tablename\ \thetable{} --- continued from previous page}} \\
88
\hline
9-
id & name & flag\_alpha & f\_alpha & t\_alpha & flag\_beta & f\_beta & t\_beta & flag\_gamma & f\_gamma & t\_gamma \\
9+
id & name & status\_alpha & f\_alpha & t\_alpha & status\_beta & f\_beta & t\_beta & status\_gamma & f\_gamma & t\_gamma \\
1010
\hline
1111
\endhead
1212
\hline

0 commit comments

Comments
 (0)