Skip to content

Commit

Permalink
Fix bug that appeared when some species had no associated gear.
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavdelius committed Oct 10, 2024
1 parent 5328ef1 commit 4a1a343
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mizerExperimental
Type: Package
Title: Extends the mizer package with experimental features
Version: 2.4.0.9007
Version: 2.4.0.9008
Author: Various contributors
Maintainer: Gustav Delius <gustav.delius@gmail.com>
Description: This mizer extension package collects contributions from the mizer
Expand Down
21 changes: 21 additions & 0 deletions R/tuneParams_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ prepare_params <- function(p) {
p <- set_species_param_default(p, "t0", 0)
p <- set_species_param_default(p, "w_mat25",
p@species_params$w_mat/(3^(1/10)))
# Make sure every species has a gear by adding a "no gear" gear
# This will be removed again at the end
sp <- species_params(p)
gp <- gear_params(p)
missing_species <- setdiff(sp$species, gp$species)
if (length(missing_species) > 0) {
gp_missing <- data.frame(species = missing_species,
gear = "no gear",
catchability = 0,
sel_func = "sigmoid_length",
l25 = 10,
l50 = 15)
gp_missing <- validGearParams(gp_missing, sp)
gear_params(p) <- dplyr::bind_rows(gp, gp_missing)
}

return(p)
}

Expand All @@ -16,6 +32,11 @@ finalise_params <- function(p) {
# Clear attribute that was only needed for the undo functionality
attr(p, "changes") <- NULL

# Remove the "no gear" gear that was added at the beginning
gp <- gear_params(p)
gp <- gp[gp$gear != "no gear", ]
gear_params(p) <- gp

# Set reproduction
if ("tuneParams_old_repro_level" %in% names(p@species_params)) {
p <- setBevertonHolt(p, reproduction_level =
Expand Down

0 comments on commit 4a1a343

Please sign in to comment.