Skip to content

Commit

Permalink
Fixes #322 + new printout format on GH (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinju authored Feb 15, 2024
1 parent f940886 commit e73d393
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ get_supported_models <- function() {
DT_predict_model[, predict_model := 1]
DT_predict_model[, c("visible", "from", "generic", "isS4") := NULL]

DT <- merge(DT_get_model_specs, DT_predict_model, by = "rn", all = TRUE, allow.cartesian = TRUE, nomatch = 0)
DT <- merge(DT_get_model_specs, DT_predict_model, by = "rn", all = TRUE, allow.cartesian = TRUE)
DT[, (colnames(DT)[-1]) := lapply(.SD, data.table::nafill, fill = 0), .SDcols = colnames(DT)[-1]]
DT[, (colnames(DT)[2:3]) := lapply(.SD, as.logical), .SDcols = colnames(DT)[2:3]]
data.table::setnames(DT, "rn", "model_class")
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/_snaps/forecast-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Output
explain_idx horizon none Temp.1 Temp.2
<int> <int> <num> <num> <num>
1: 152 1 77.88 -0.3972 -1.3912
2: 153 1 77.88 -6.6177 -0.1835
3: 152 2 77.88 -0.3285 -1.2034
Expand All @@ -25,13 +26,15 @@
Output
explain_idx horizon none Temp.1 Temp.2 Wind.1 Wind.2 Wind.F1 Wind.F2
<int> <int> <num> <num> <num> <num> <num> <num> <num>
1: 149 1 77.88 -0.9588 -5.044 1.0543 -2.8958 -2.6627 NA
2: 150 1 77.88 1.1553 -3.137 -2.8802 0.7196 -1.4930 NA
3: 149 2 77.88 0.1327 -5.048 0.3337 -2.8249 -2.3014 -1.1764
4: 150 2 77.88 1.6007 -2.399 -2.8146 0.4646 -0.7938 0.4662
5: 149 3 77.88 -1.3878 -5.014 0.7964 -1.3881 -1.9652 -0.3295
6: 150 3 77.88 1.6690 -2.556 -2.3821 0.3835 -0.8644 -0.1648
Wind.F3
<num>
1: NA
2: NA
3: NA
Expand All @@ -49,6 +52,7 @@
Output
explain_idx horizon none Temp.1 Temp.2
<int> <int> <num> <num> <num>
1: 149 1 77.88 -1.7273 -7.033
2: 150 1 77.88 -0.2229 -4.492
3: 149 2 77.88 -1.7273 -7.033
Expand All @@ -66,6 +70,7 @@
Output
explain_idx horizon none Temp Wind
<int> <int> <num> <num> <num>
1: 149 1 77.88 -5.3063 -5.201
2: 150 1 77.88 -1.4435 -4.192
3: 149 2 77.88 -3.6824 -7.202
Expand Down Expand Up @@ -3620,6 +3625,7 @@
data length [2] is not a sub-multiple or multiple of the number of rows [3]
Output
explain_idx horizon none Wind.F1 Wind.F2 Wind.F3
<int> <int> <num> <num> <num> <num>
1: 149 1 77.88 -9.391 NA NA
2: 150 1 77.88 -4.142 NA NA
3: 149 2 77.88 -4.699 -4.6989 NA
Expand Down
28 changes: 28 additions & 0 deletions tests/testthat/_snaps/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.537 8.269 17.517 -5.581 -3.066
2: 42.44 2.250 -3.345 -5.232 -5.581 -1.971
3: 42.44 3.708 -18.610 -1.440 -2.541 1.316
Expand All @@ -14,6 +15,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.537 8.269 17.517 -5.581 -3.066
2: 42.44 2.250 -3.345 -5.232 -5.581 -1.971
3: 42.44 3.708 -18.610 -1.440 -2.541 1.316
Expand All @@ -24,6 +26,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -13.252 15.541 12.826 -5.77179 3.259
2: 42.44 2.758 -3.325 -7.992 -7.12800 1.808
3: 42.44 6.805 -22.126 3.730 -0.09235 -5.885
Expand All @@ -34,6 +37,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -5.795 15.320 8.557 -7.547 2.066
2: 42.44 3.266 -3.252 -7.693 -7.663 1.462
3: 42.44 4.290 -24.395 6.739 -1.006 -3.197
Expand All @@ -52,6 +56,7 @@
empirical.eta force set to 1 for empirical.type = 'independence'
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.537 8.269 17.517 -5.581 -3.066
2: 42.44 2.250 -3.345 -5.232 -5.581 -1.971
3: 42.44 3.708 -18.610 -1.440 -2.541 1.316
Expand All @@ -62,6 +67,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -15.66 6.823 17.5092 0.2463 3.6847
2: 42.44 10.70 -1.063 -10.6804 -13.0305 0.1983
3: 42.44 14.65 -19.946 0.9675 -7.3433 -5.8946
Expand All @@ -72,6 +78,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -14.98 6.3170 17.4103 0.2876 3.5623
2: 42.44 12.42 0.1482 -10.2338 -16.4096 0.1967
3: 42.44 15.74 -19.7250 0.9992 -8.6950 -5.8886
Expand All @@ -82,6 +89,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -8.117 7.438 14.0026 0.8602 -1.5813
2: 42.44 5.278 -5.219 -12.1079 -0.8073 -1.0235
3: 42.44 7.867 -25.995 -0.1377 -0.2368 0.9342
Expand All @@ -92,6 +100,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -5.960 7.046 13.863 -0.274 -2.074
2: 42.44 4.482 -4.892 -10.491 -1.659 -1.319
3: 42.44 6.587 -25.533 1.279 -1.043 1.142
Expand All @@ -102,6 +111,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -9.124 9.509 17.139 -1.4711 -3.451
2: 42.44 5.342 -6.097 -8.232 -2.8129 -2.079
3: 42.44 6.901 -21.079 -4.687 0.1494 1.146
Expand All @@ -112,6 +122,7 @@
(out <- code)
Output
none Month_factor Ozone_sub30_factor Solar.R_factor Wind_factor
<num> <num> <num> <num> <num>
1: 42.44 -6.206 15.38 -6.705 -2.973
2: 42.44 -5.764 -17.71 21.866 -13.219
3: 42.44 7.101 -21.78 1.730 -5.413
Expand All @@ -122,6 +133,7 @@
(out <- code)
Output
none Month_factor Ozone_sub30_factor Solar.R_factor Wind_factor
<num> <num> <num> <num> <num>
1: 42.44 13.656 -19.73 4.369 -16.659
2: 42.44 -5.448 11.31 -11.445 5.078
3: 42.44 -7.493 -12.27 19.672 -14.744
Expand All @@ -132,6 +144,7 @@
(out <- code)
Output
none Month_factor Ozone_sub30_factor Solar.R_factor Wind_factor
<num> <num> <num> <num> <num>
1: 42.44 -5.252 13.95 -7.041 -2.167
2: 42.44 -5.252 -15.61 20.086 -14.050
3: 42.44 4.833 -15.61 0.596 -8.178
Expand All @@ -142,6 +155,7 @@
(out <- code)
Output
none S1 S2 S3 S4
<num> <num> <num> <num> <num>
1: 4.895 -0.5261 0.7831 -0.21023 -0.3885
2: 4.895 -0.6310 1.6288 -0.04498 -2.9298

Expand All @@ -151,6 +165,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -8.746 9.03 15.366 -2.619 -0.4293
2: 42.44 3.126 -4.50 -7.789 -4.401 -0.3161
3: 42.44 7.037 -22.86 -1.837 0.607 -0.5181
Expand All @@ -161,6 +176,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -9.294 9.327 17.31641 -1.754 -2.9935
2: 42.44 5.194 -5.506 -8.45049 -2.935 -2.1810
3: 42.44 6.452 -22.967 -0.09553 -1.310 0.3519
Expand All @@ -171,6 +187,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -6.952 10.777 12.160 -3.641 0.25767
2: 42.44 2.538 -2.586 -8.503 -5.376 0.04789
3: 42.44 5.803 -22.122 3.362 -2.926 -1.68514
Expand All @@ -181,6 +198,7 @@
(out <- code)
Output
none Solar.R Wind Temp Day Month_factor
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.730 7.750 17.753 -2.601 -7.588
2: 42.44 2.338 -3.147 -5.310 -1.676 -7.588
3: 42.44 3.857 -17.469 -1.466 1.099 3.379
Expand All @@ -191,6 +209,7 @@
(out <- code)
Output
none Solar.R Wind Temp Day Month_factor
<num> <num> <num> <num> <num> <num>
1: 42.44 -9.165 11.815 13.184 -0.4473 -4.802
2: 42.44 3.652 -5.782 -6.524 -0.4349 -6.295
3: 42.44 6.268 -21.441 -7.323 1.6330 10.262
Expand All @@ -201,6 +220,7 @@
(out <- code)
Output
none Solar.R Wind Temp Day Month_factor
<num> <num> <num> <num> <num> <num>
1: 42.44 -7.886 10.511 16.292 -0.9519 -7.382
2: 42.44 5.001 -4.925 -7.015 -1.0954 -7.349
3: 42.44 5.505 -20.583 -4.328 0.7825 8.023
Expand All @@ -211,6 +231,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.537 8.269 17.517 -5.581 -3.066
2: 42.44 2.250 -3.345 -5.232 -5.581 -1.971
3: 42.44 3.708 -18.610 -1.440 -2.541 1.316
Expand All @@ -225,6 +246,7 @@
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.537 8.269 17.517 -5.581 -3.066
2: 42.44 2.250 -3.345 -5.232 -5.581 -1.971
3: 42.44 3.708 -18.610 -1.440 -2.541 1.316
Expand All @@ -239,6 +261,7 @@
Output
none Solar.R Wind Temp Day Month_factor
<num> <num> <num> <num> <num> <num>
1: 42.44 -5.603 13.05 20.43 0.08508 -0.2664
2: 42.44 4.645 -12.57 -16.65 1.29133 -2.1574
3: 42.44 5.451 -14.01 -19.72 1.32503 6.3851
Expand All @@ -249,6 +272,7 @@
(out <- code)
Output
none Solar.R Wind
<num> <num> <num>
1: 42.44 -13.818 10.579
2: 42.44 4.642 -6.287
3: 42.44 4.452 -34.602
Expand All @@ -259,6 +283,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -9.124 9.509 17.139 -1.4711 -3.451
2: 42.44 5.342 -6.097 -8.232 -2.8129 -2.079
3: 42.44 6.901 -21.079 -4.687 0.1494 1.146
Expand All @@ -269,6 +294,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.537 8.269 17.517 -5.581 -3.066
2: 42.44 2.250 -3.345 -5.232 -5.581 -1.971
3: 42.44 3.708 -18.610 -1.440 -2.541 1.316
Expand All @@ -279,6 +305,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -13.252 15.541 12.826 -5.77179 3.259
2: 42.44 2.758 -3.325 -7.992 -7.12800 1.808
3: 42.44 6.805 -22.126 3.730 -0.09235 -5.885
Expand All @@ -289,6 +316,7 @@
(out <- code)
Output
none Solar.R Wind Temp Month Day
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.537 8.269 17.517 -5.581 -3.066
2: 42.44 2.250 -3.345 -5.232 -5.581 -1.971
3: 42.44 3.708 -18.610 -1.440 -2.541 1.316
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/_snaps/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
Output
none Solar.R Wind Temp Day Month_factor
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.730 7.750 17.753 -2.601 -7.588
2: 42.44 2.338 -3.147 -5.310 -1.676 -7.588
3: 42.44 3.857 -17.469 -1.466 1.099 3.379
Expand All @@ -45,6 +46,7 @@
Output
none Solar.R Wind Temp Day Month_factor
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.730 7.750 17.753 -2.601 -7.588
2: 42.44 2.338 -3.147 -5.310 -1.676 -7.588
3: 42.44 3.857 -17.469 -1.466 1.099 3.379
Expand All @@ -64,6 +66,7 @@
Output
none Solar.R Wind Temp Day Month_factor
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.730 7.750 17.753 -2.601 -7.588
2: 42.44 2.338 -3.147 -5.310 -1.676 -7.588
3: 42.44 3.857 -17.469 -1.466 1.099 3.379
Expand All @@ -84,6 +87,7 @@
Output
none Solar.R Wind Temp Day Month_factor
<num> <num> <num> <num> <num> <num>
1: 42.44 -4.730 7.750 17.753 -2.601 -7.588
2: 42.44 2.338 -3.147 -5.310 -1.676 -7.588
3: 42.44 3.857 -17.469 -1.466 1.099 3.379
Expand Down

0 comments on commit e73d393

Please sign in to comment.