prioritizr / prioritizr
Showing 2 of 160 files from the diff.
Other files ignored by Codecov
docs/index.html has changed.
docs/pkgdown.yml has changed.
docs/404.html has changed.
docs/authors.html has changed.
README.md has changed.
NEWS.md has changed.
DESCRIPTION has changed.

@@ -288,19 +288,25 @@
Loading
288 288
  assertthat::assert_that(
289 289
    inherits(x, "ConservationProblem"),
290 290
    is.matrix(solution))
291 +
  # convert NAs in solution to zeros
292 +
  solution[is.na(solution)] <- 0
291 293
  # calculate amount of each feature in each planning unit
292 294
  total <- x$feature_abundances_in_total_units()
293 -
  held <-
294 -
    vapply(
295 -
      seq_len(x$number_of_zones()),
296 -
      FUN.VALUE = numeric(nrow(x$data$rij_matrix[[1]])),
297 -
      function(i) {
298 -
        rowSums(
299 -
          x$data$rij_matrix[[i]] *
300 -
            matrix(solution[, i], ncol = nrow(solution),
301 -
                   nrow = nrow(x$data$rij_matrix[[1]]), byrow = TRUE),
302 -
          na.rm = TRUE)
303 -
    })
295 +
  held <- vapply(
296 +
    seq_len(x$number_of_zones()),
297 +
    FUN.VALUE = numeric(nrow(x$data$rij_matrix[[1]])),
298 +
    function(i) {
299 +
      as.numeric(
300 +
        x$data$rij_matrix[[i]] %*%
301 +
        Matrix::Matrix(
302 +
          solution[, i],
303 +
          ncol = 1,
304 +
          nrow = nrow(solution),
305 +
          sparse = TRUE
306 +
        )
307 +
      )
308 +
    }
309 +
  )
304 310
  # prepare output
305 311
  if (x$number_of_zones() == 1) {
306 312
    out <- tibble::tibble(
@@ -310,8 +316,8 @@
Loading
310 316
      absolute_held = unname(c(held)),
311 317
      relative_held = unname(c(held / total)))
312 318
  } else {
313 -
    total <- c(rowSums(total), c(total))
314 -
    held <- c(rowSums(held), c(held))
319 +
    total <- c(Matrix::rowSums(total), c(total))
320 +
    held <- c(Matrix::rowSums(held), c(held))
315 321
    out <- tibble::tibble(
316 322
      summary =
317 323
        rep(c("overall", x$zone_names()), each = x$number_of_features()),

@@ -931,14 +931,14 @@
Loading
931 931
    if (is.null(names(rij_matrix)))
932 932
      names(rij_matrix) <- as.character(seq_along(rij_matrix))
933 933
    # calculate feature abundances in total units
934 -
    fatu <- vapply(rij_matrix, rowSums, numeric(nrow(rij_matrix[[1]])),
934 +
    fatu <- vapply(rij_matrix, Matrix::rowSums, numeric(nrow(rij_matrix[[1]])),
935 935
                   na.rm = TRUE)
936 936
    if (!is.matrix(fatu))
937 937
      fatu <- matrix(fatu, nrow = nrow(features), ncol = length(rij_matrix))
938 938
    rownames(fatu) <- as.character(features$name)
939 939
    colnames(fatu) <- names(rij_matrix)
940 940
    # convert rij matrices to sparse format if needed
941 -
    pos <- which(rowSums(!is.na(x)) > 0)
941 +
    pos <- which(Matrix::rowSums(!is.na(x)) > 0)
942 942
    rij <- lapply(rij_matrix, function(z) {
943 943
      if (inherits(z, "dgCMatrix")) {
944 944
        z@x[which(is.na(z@x))] <- 0
@@ -1013,7 +1013,7 @@
Loading
1013 1013
      return(m)
1014 1014
    })
1015 1015
    # calculate feature abundances in total units
1016 -
    fatu <- vapply(rij, rowSums, numeric(number_of_features(features)),
1016 +
    fatu <- vapply(rij, Matrix::rowSums, numeric(number_of_features(features)),
1017 1017
                   na.rm = TRUE)
1018 1018
    if (!is.matrix(fatu))
1019 1019
      fatu <- matrix(fatu, nrow = number_of_features(features),
@@ -1021,8 +1021,9 @@
Loading
1021 1021
    rownames(fatu) <- feature_names(features)
1022 1022
    colnames(fatu) <- zone_names(features)
1023 1023
    # create rij matrix
1024 -
    pos <- which(rowSums(!is.na(as.matrix(
1025 -
             x2[, cost_column, drop = FALSE]))) > 0)
1024 +
    pos <- which(
1025 +
      rowSums(!is.na(as.matrix(x2[, cost_column, drop = FALSE]))) > 0
1026 +
    )
1026 1027
    rij <- lapply(rij, function(x) x[, pos, drop = FALSE])
1027 1028
    names(rij) <- zone_names(features)
1028 1029
    # create ConservationProblem object
Files Coverage
R 98.39%
src 98.22%
Project Totals (128 files) 98.34%
1
coverage:
2
  status:
3
    project:
4
      default:
5
        target: auto
6
        threshold: 20%
7
    patch:
8
      default:
9
        target: auto
10
        threshold: 20%
11
        informational: true
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