You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
implement load_function kwarg for collect_results! (#424)
The changes in this branch are a follow up from a previous pull request
based on commit 6e6ff07 in PR #421. In that PR there were issues
with whitespace changes inadvertantly coming from the autoformatter
in vscode. Reverting the whitespace only changes proved to be more
difficult than anticicpated.
So to resolve this, this branch was created and a new PR will be created
from it. The whitespace issues are gone but all the feedback and changes
from the original PR are retained.
The commit makes the following changes.
- add the `load_function` kwarg to `collect_results`. This allows
customizing how data is loaded from file before being processed into a
dataframe by `collect_results`.
- add a test to `update_result_tests.jl`
- update docstring of `collect_results`
- increase package version to 2.16.0
- update `CHANGELOG.md`
All tests passed, 589 of 589.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
# 2.16.0
2
+
3
+
- Add `load_function` keyword argument to `collect_results` to customize how data is loaded from file before being converted to a dataframe by `collect_results`
4
+
1
5
# 2.15.0
2
6
3
7
- Add `wload_kwargs` to `produce_or_load` to allow passing kwargs to `wload`
Copy file name to clipboardExpand all lines: src/result_collection.jl
+9-8Lines changed: 9 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,7 @@ See also [`collect_results`](@ref).
50
50
* `black_list = [:gitcommit, :gitpatch, :script]`: List of keys not to include from result-file.
51
51
* `special_list = []`: List of additional (derived) key-value pairs
52
52
to put in `df` as explained below.
53
+
* `load_function = wload`: Load function. Defaults to `wload`. You may want to specify a custom load function for example if you store results as a struct and you want the fields of the struct to form the columns of the dataframe. The struct is saved to file as a one-element dictionary so the dataframe will only have a single column. To work around this you could convert it to a dictionary by specifying `load_function = (filename) -> struct2dict(wload(filename)["mykey"])`. This way `collect_results` will receive a `Dict` whose keys are the fields of the struct.
53
54
54
55
`special_list` is a `Vector` where each entry
55
56
is a derived quantity to be included in `df`. There are two types of entries.
@@ -90,6 +91,7 @@ function collect_results!(filename, folder;
90
91
newfile =false, # keyword only for defining collect_results without !
91
92
rinclude = [r""],
92
93
rexclude = [r"^\b$"],
94
+
load_function = wload,
93
95
kwargs...)
94
96
95
97
@assertall(eltype(r) <:Regexfor r in (rinclude, rexclude)) "Elements of `rinclude` and `rexclude` must be Regex expressions."
@@ -100,7 +102,7 @@ function collect_results!(filename, folder;
100
102
mtimes =Dict{String,Float64}()
101
103
else
102
104
verbose &&@info"Loading existing result collection..."
103
-
data =wload(filename)
105
+
data =load_function(filename)
104
106
df = data["df"]
105
107
# Check if we have pre-recorded mtimes (if not this could be because of an old results database).
106
108
if"mtime"∈keys(data)
@@ -170,7 +172,7 @@ function collect_results!(filename, folder;
0 commit comments