Skip to content

Commit

Permalink
Fixed bug that had led newCommunityParams() to set up resource para…
Browse files Browse the repository at this point in the history
…meters differently since version 2.4.0. Fixes #293
  • Loading branch information
gustavdelius committed Oct 13, 2024
1 parent 801a34e commit d81f793
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 86 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# mizer 2.5.1.9006

- Fixed bug that had led `newCommunityParams()` to set up resource parameters
differently since version 2.4.0 (#293)
- `addSpecies()` now correctly preserves all `species_params` of the existing
model.
- `addSpecies()` no longer requires new species to grow to maximum size, only
Expand Down
1 change: 1 addition & 0 deletions R/wrapper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ newCommunityParams <- function(max_w = 1e6,
params <-
newMultispeciesParams(species_params, no_w = no_w, min_w_pp = min_w_pp,
p = p, n = n, lambda = lambda, min_w = min_w,
kappa = kappa,
resource_capacity = kappa,
resource_rate = r_pp,
w_pp_cutoff = w_pp_cutoff,
Expand Down
160 changes: 74 additions & 86 deletions tests/testthat/_snaps/backwards_compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -4243,64 +4243,58 @@
Output
w
sp 0.001 0.00123 0.00152 0.00187 0.00231
Community 2.363303e-13 2.745813e-13 3.190233e-13 3.706585e-13 4.30651e-13
Community 2.363303e-05 2.745813e-05 3.190233e-05 3.706585e-05 4.30651e-05
w
sp 0.00285 0.00351 0.00433 0.00534 0.00658
Community 5.003536e-13 5.813377e-13 6.754295e-13 7.847504e-13 9.117653e-13
Community 5.003536e-05 5.813377e-05 6.754295e-05 7.847504e-05 9.117653e-05
w
sp 0.00811 0.01 0.0123 0.0152 0.0187
Community 1.059338e-12 1.230796e-12 1.430005e-12 1.661457e-12 1.93037e-12
Community 0.0001059338 0.0001230796 0.0001430005 0.0001661457 0.000193037
w
sp 0.0231 0.0285 0.0351 0.0433 0.0534
Community 2.242808e-12 2.605816e-12 3.027577e-12 3.517602e-12 4.08694e-12
Community 0.0002242808 0.0002605816 0.0003027577 0.0003517602 0.000408694
w
sp 0.0658 0.0811 0.1 0.123 0.152
Community 4.748427e-12 5.516978e-12 6.409922e-12 7.447393e-12 8.652783e-12
Community 0.0004748427 0.0005516978 0.0006409922 0.0007447393 0.0008652783
w
sp 0.187 0.231 0.285 0.351 0.433
Community 1.005327e-11 1.168043e-11 1.357095e-11 1.576746e-11 1.831949e-11
sp 0.187 0.231 0.285 0.351 0.433
Community 0.001005327 0.001168043 0.001357095 0.001576746 0.001831949
w
sp 0.534 0.658 0.811 1 1.23
Community 2.128457e-11 2.472956e-11 2.873214e-11 3.338254e-11 3.878564e-11
sp 0.534 0.658 0.811 1 1.23
Community 0.002128457 0.002472956 0.002873214 0.003338254 0.003878564
w
sp 1.52 1.87 2.31 2.85 3.51
Community 4.506324e-11 5.235691e-11 6.083107e-11 7.067682e-11 8.211614e-11
w
sp 4.33 5.34 6.58 8.11 10
Community 9.540695e-11 1.108489e-10 1.287903e-10 1.496355e-10 1.738546e-10
w
sp 12.3 15.2 18.7 23.1 28.5
Community 2.019936e-10 2.34687e-10 2.726721e-10 3.168051e-10 3.680812e-10
sp 1.52 1.87 2.31 2.85 3.51
Community 0.004506324 0.005235691 0.006083107 0.007067682 0.008211614
w
sp 35.1 43.3 53.4 65.8 81.1
Community 4.276566e-10 4.968745e-10 5.772956e-10 6.707331e-10 7.792938e-10
sp 4.33 5.34 6.58 8.11 10 12.3
Community 0.009540695 0.01108489 0.01287903 0.01496355 0.01738546 0.02019936
w
sp 100 123 152 187 231
Community 9.054256e-10 1.051972e-09 1.222238e-09 1.420062e-09 1.649905e-09
sp 15.2 18.7 23.1 28.5 35.1 43.3
Community 0.0234687 0.02726721 0.03168051 0.03680812 0.04276566 0.04968745
w
sp 285 351 433 534 658
Community 1.916948e-09 2.227214e-09 2.587697e-09 3.006525e-09 3.493143e-09
sp 53.4 65.8 81.1 100 123 152
Community 0.05772956 0.06707331 0.07792938 0.09054256 0.1051972 0.1222238
w
sp 811 1000 1230 1520 1870
Community 4.058522e-09 4.71541e-09 5.478617e-09 6.365352e-09 7.39561e-09
sp 187 231 285 351 433 534
Community 0.1420062 0.1649905 0.1916948 0.2227214 0.2587697 0.3006525
w
sp 2310 2850 3510 4330 5340
Community 8.592618e-09 9.983366e-09 1.159921e-08 1.347659e-08 1.565783e-08
sp 658 811 1000 1230 1520 1870 2310
Community 0.3493143 0.4058522 0.471541 0.5478617 0.6365352 0.739561 0.8592618
w
sp 6580 8110 10000 12300 15200
Community 1.819211e-08 2.113657e-08 2.455761e-08 2.853235e-08 3.315043e-08
sp 2850 3510 4330 5340 6580 8110 10000
Community 0.9983366 1.159921 1.347659 1.565783 1.819211 2.113657 2.455761
w
sp 18700 23100 28500 35100 43300
Community 3.851595e-08 4.474991e-08 5.199286e-08 6.04081e-08 7.018539e-08
sp 12300 15200 18700 23100 28500 35100 43300
Community 2.853235 3.315043 3.851595 4.474991 5.199286 6.04081 7.018539
w
sp 53400 65800 81100 1e+05 123000
Community 8.154516e-08 9.474357e-08 1.100782e-07 1.278948e-07 1.48595e-07
sp 53400 65800 81100 1e+05 123000 152000 187000
Community 8.154516 9.474357 11.00782 12.78948 14.8595 17.26457 20.05891
w
sp 152000 187000 231000 285000 351000
Community 1.726457e-07 2.005891e-07 2.330552e-07 2.707761e-07 3.146023e-07
sp 231000 285000 351000 433000 534000 658000 811000
Community 23.30552 27.07761 31.46023 36.55219 42.4683 49.34196 57.32815
w
sp 433000 534000 658000 811000 1e+06
Community 3.655219e-07 4.24683e-07 4.934196e-07 5.732815e-07 6.660693e-07
sp 1e+06
Community 66.60693

---

Expand Down Expand Up @@ -4644,31 +4638,31 @@
params@initial_n_pp
Output
8.11e-11 1e-10 1.23e-10 1.52e-10 1.87e-10 2.31e-10
4.856950e+31 3.162278e+31 2.058905e+31 1.340518e+31 8.727887e+30 5.682579e+30
4.856950e+23 3.162278e+23 2.058905e+23 1.340518e+23 8.727887e+22 5.682579e+22
2.85e-10 3.51e-10 4.33e-10 5.34e-10 6.58e-10 8.11e-10
3.699830e+30 2.408897e+30 1.568392e+30 1.021153e+30 6.648555e+29 4.328761e+29
3.699830e+22 2.408897e+22 1.568392e+22 1.021153e+22 6.648555e+21 4.328761e+21
1e-09 1.23e-09 1.52e-09 1.87e-09 2.31e-09 2.85e-09
2.818383e+29 1.835001e+29 1.194738e+29 7.778737e+28 5.064604e+28 3.297477e+28
2.818383e+21 1.835001e+21 1.194738e+21 7.778737e+20 5.064604e+20 3.297477e+20
3.51e-09 4.33e-09 5.34e-09 6.58e-09 8.11e-09 1e-08
2.146931e+28 1.397831e+28 9.101038e+27 5.925531e+27 3.858013e+27 2.511886e+27
2.146931e+20 1.397831e+20 9.101038e+19 5.925531e+19 3.858013e+19 2.511886e+19
1.23e-08 1.52e-08 1.87e-08 2.31e-08 2.85e-08 3.51e-08
1.635447e+27 1.064811e+27 6.932807e+26 4.513833e+26 2.938880e+26 1.913455e+26
1.635447e+19 1.064811e+19 6.932807e+18 4.513833e+18 2.938880e+18 1.913455e+18
4.33e-08 5.34e-08 6.58e-08 8.11e-08 1e-07 1.23e-07
1.245818e+26 8.111308e+25 5.281135e+25 3.438457e+25 2.238721e+25 1.457593e+25
1.245818e+18 8.111308e+17 5.281135e+17 3.438457e+17 2.238721e+17 1.457593e+17
1.52e-07 1.87e-07 2.31e-07 2.85e-07 3.51e-07 4.33e-07
9.490142e+24 6.178870e+24 4.022958e+24 2.619279e+24 1.705368e+24 1.110336e+24
9.490142e+16 6.178870e+16 4.022958e+16 2.619279e+16 1.705368e+16 1.110336e+16
5.34e-07 6.58e-07 8.11e-07 1e-06 1.23e-06 1.52e-06
7.229211e+23 4.706817e+23 3.064528e+23 1.995262e+23 1.299081e+23 8.458098e+22
7.229211e+15 4.706817e+15 3.064528e+15 1.995262e+15 1.299081e+15 8.458098e+14
1.87e-06 2.31e-06 2.85e-06 3.51e-06 4.33e-06 5.34e-06
5.506924e+22 3.585465e+22 2.334435e+22 1.519911e+22 9.895883e+21 6.443041e+21
5.506924e+14 3.585465e+14 2.334435e+14 1.519911e+14 9.895883e+13 6.443041e+13
6.58e-06 8.11e-06 1e-05 1.23e-05 1.52e-05 1.87e-05
4.194955e+21 2.731264e+21 1.778279e+21 1.157808e+21 7.538288e+20 4.908051e+20
4.194955e+13 2.731264e+13 1.778279e+13 1.157808e+13 7.538288e+12 4.908051e+12
2.31e-05 2.85e-05 3.51e-05 4.33e-05 5.34e-05 6.58e-05
3.195549e+20 2.080568e+20 1.354622e+20 8.819715e+19 5.742367e+19 3.738757e+19
3.195549e+12 2.080568e+12 1.354622e+12 8.819715e+11 5.742367e+11 3.738757e+11
8.11e-05 1e-04 0.000123 0.000152 0.000187 0.000231
2.434241e+19 1.584893e+19 1.031897e+19 6.718506e+18 4.374305e+18 2.848036e+18
2.434241e+11 1.584893e+11 1.031897e+11 6.718506e+10 4.374305e+10 2.848036e+10
0.000285 0.000351 0.000433 0.000534 0.000658 0.000811
1.854308e+18 1.207308e+18 7.860579e+17 5.117890e+17 3.332171e+17 2.169520e+17
1.854308e+10 1.207308e+10 7.860579e+09 5.117890e+09 3.332171e+09 2.169520e+09
0.001 0.00123 0.00152 0.00187 0.00231 0.00285
0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
0.00351 0.00433 0.00534 0.00658 0.00811 0.01
Expand Down Expand Up @@ -4714,54 +4708,48 @@
i Please use `newMultispeciesParams()` instead.
Output
w
sp 0.001 0.00123 0.00152 0.00187 0.00231
Community 987318686045 974100938721 960281073191 945729266586 9.30306e+11
sp 0.001 0.00123 0.00152 0.00187 0.00231 0.00285 0.00351
Community 9873.187 9770.39 9668.664 9567.996 9468.377 9369.795 9272.239
w
sp 0.00285 0.00351 0.00433 0.00534 0.00658
Community 913864922317 896256788647 877334263805 856957692389 835001547513
w
sp 0.00811 0.01 0.0123 0.0152 0.0187
Community 811361341429 785960660679 758757931788 729752483985 698989465461
sp 0.00433 0.00534 0.00658 0.00811 0.01 0.0123 0.0152
Community 9175.699 9080.165 8985.625 8892.069 8799.487 8707.869 8617.205
w
sp 0.0231 0.0285 0.0351 0.0433 0.0534
Community 666563194240 632618585712 597350394817 561000136499 523850694576
sp 0.0187 0.0231 0.0285 0.0351 0.0433 0.0534 0.0658
Community 8527.486 8438.7 8350.839 8263.892 8177.851 8092.705 8008.446
w
sp 0.0658 0.0811 0.1 0.123 0.152
Community 486218785082 448445592132 4.10886e+11 373897178920 337826542663
sp 0.0811 0.1 0.123 0.152 0.187 0.231 0.285
Community 7925.065 7842.551 7760.897 7680.092 7600.13 7520.999 7442.693
w
sp 0.187 0.231 0.285 0.351 0.433
Community 303000720547 269715147086 238225403290 208740525675 181418586591
sp 0.351 0.433 0.534 0.658 0.811 1 1.23
Community 7365.201 7288.517 7212.631 7137.535 7063.221 6989.681 6916.906
w
sp 0.534 0.658 0.811 1 1.23
Community 156364664215 133631163304 113220303088 95088467710 79152025578
sp 1.52 1.87 2.31 2.85 3.51 4.33 5.34
Community 6844.89 6773.623 6703.098 6633.307 6564.243 6495.898 6428.264
w
sp 1.52 1.87 2.31 2.85 3.51
Community 65294171460 53372329870 43225677585 34682391362 27566296589
sp 6.58 8.11 10 12.3 15.2 18.7 23.1
Community 6361.335 6295.103 6229.56 6164.699 6100.514 6036.997 5974.142
w
sp 4.33 5.34 6.58 8.11 10
Community 21702675273 16923078864 13069075473 9994935837 7569323723
w
sp 12.3 15.2 18.7 23.1 28.5 35.1
Community 5676101924 4214394140 3098056804 2254715444 1624510330 1158678900
sp 28.5 35.1 43.3 53.4 65.8 81.1 100
Community 5911.941 5850.387 5789.475 5729.197 5669.546 5610.516 5552.101
w
sp 43.3 53.4 65.8 81.1 100 123
Community 818080990 571749643 395527591 270828809 183546906 123117961
sp 123 152 187 231 285 351 433
Community 5494.294 5437.089 5380.48 5324.46 5269.023 5214.163 5159.875
w
sp 152 187 231 285 351 433 534
Community 81734812 53702509 34920162 22472265 14312146 9020987 5627401
sp 534 658 811 1000 1230 1520 1870
Community 5106.152 5052.988 5000.378 4948.315 4896.795 4845.811 4795.358
w
sp 658 811 1000 1230 1520 1870 2310 2850
Community 3474520 2123582 1285077 770284.7 457662.3 269870.8 158284 92691.55
sp 2310 2850 3510 4330 5340 6580 8110
Community 4745.43 4696.022 4647.128 4598.743 4550.863 4503.48 4456.591
w
sp 3510 4330 5340 6580 8110 10000 12300
Community 54546.32 32595.73 20092.93 13040.02 9095.604 6904.419 5691.085
sp 10000 12300 15200 18700 23100 28500 35100
Community 4410.191 4364.273 4318.833 4273.867 4229.369 4185.334 4141.757
w
sp 15200 18700 23100 28500 35100 43300 53400
Community 5017.133 4637.471 4416.682 4280.801 4189.895 4122.648 4067.812
sp 43300 53400 65800 81100 1e+05 123000 152000
Community 4098.634 4055.961 4013.731 3971.941 3930.586 3889.662 3849.164
w
sp 65800 81100 1e+05 123000 152000 187000 231000
Community 4019.518 3974.736 3931.922 3890.294 3849.46 3809.224 3769.491
sp 187000 231000 285000 351000 433000 534000 658000
Community 3809.088 3769.429 3730.183 3691.345 3652.912 3614.879 3577.242
w
sp 285000 351000 433000 534000 658000 811000 1e+06
Community 3730.211 3691.358 3652.917 3614.881 3577.243 3539.997 3503.139
sp 811000 1e+06
Community 3539.996 3503.139

0 comments on commit d81f793

Please sign in to comment.