sizespectrum / mizer
Showing 1 of 1 files from the diff.

@@ -48,6 +48,12 @@
Loading
48 48
        msg <- "The later entries of dw_full should be equal to those of dw."
49 49
        errors <- c(errors, msg)
50 50
    }
51 +
    # Check w_min_idx
52 +
    if (any(object@species_params$w_min < object@w[object@w_min_idx]) ||
53 +
        any(object@species_params$w_min > object@w[object@w_min_idx + 1])) {
54 +
        msg <- "The `w_min_idx` should point to the start of the size bin containing the egg size `w_min`."
55 +
        errors <- c(errors, msg)
56 +
    }
51 57
52 58
    # Check the array dimensions are good ----
53 59
    # Bit tricky this one as I don't know of a way to compare lots of vectors 
@@ -555,14 +561,7 @@
Loading
555 561
    vec1 <- as.numeric(rep(NA, no_w_full))
556 562
    names(vec1) <- signif(w_full, 3)
557 563
    
558 -
    # Round down w_min to lie on grid points and store the indices of these
559 -
    # grid points in w_min_idx
560 -
    w_min_idx <- as.vector(suppressWarnings(
561 -
        tapply(species_params$w_min, 1:no_sp,
562 -
               function(w_min, wx) max(which(wx <= w_min)), wx = w)))
563 -
    # Due to rounding errors this might happen:
564 -
    w_min_idx[w_min_idx == -Inf] <- 1
565 -
    names(w_min_idx) <- species_names
564 +
    w_min_idx <- get_w_min_idx(species_params, w)
566 565
    
567 566
    # Colour and linetype scales ----
568 567
    # for use in plots
@@ -808,6 +807,20 @@
Loading
808 807
        params <- upgradeParams(params)
809 808
        warning("You need to upgrade your MizerParams object with `upgradeParams()`.")
810 809
    }
810 +
    params@w_min_idx <- get_w_min_idx(params@species_params, params@w)
811 811
    validObject(params)
812 812
    params
813 +
}
814 +
815 +
# helper function to calculate w_min_idx slot
816 +
get_w_min_idx <- function(species_params, w) {
817 +
    # Round down w_min to lie on grid points and store the indices of these
818 +
    # grid points in w_min_idx
819 +
    w_min_idx <- as.vector(suppressWarnings(
820 +
        tapply(species_params$w_min, seq_len(nrow(species_params)),
821 +
               function(w_min, wx) max(which(wx <= w_min)), wx = w)))
822 +
    # Due to rounding errors this might happen:
823 +
    w_min_idx[w_min_idx == -Inf] <- 1
824 +
    names(w_min_idx) <- as.character(species_params$species)
825 +
    w_min_idx
813 826
}
Files Coverage
R 91.79%
src/inner_project_loop.cpp 100.00%
Project Totals (30 files) 91.81%
Notifications are pending CI completion. Periodically Codecov will check the CI state, when complete notifications will be submitted. Push notifications now.
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
    patch:
10
      default:
11
        target: auto
12
        threshold: 1%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading