-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from r-spatialecology/utility-functions
Utility functions
- Loading branch information
Showing
23 changed files
with
65 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: vectormetrics | ||
Title: Landscape Metrics for Categorical Map Patterns in Vector Data | ||
Version: 0.2.3 | ||
Version: 0.2.4 | ||
Authors@R: | ||
c(person("Tomasz", "Matuszek", role = c("cre", "aut"), | ||
email = "[email protected]"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
testthat::test_that("check vm_p_circum value", { | ||
expect_equal(vm_p_circum(square, "class")$value, 1.41, tolerance = 0.01) | ||
expect_equal(vm_p_circum(diamond, "class")$value, 8, tolerance = 0.01) | ||
expect_equal(vm_p_circum(circle, "class")$value, 2) | ||
testthat::test_that("check get_circum_diam value", { | ||
expect_equal(get_circum_diam(square, "class")$value, 1.41, tolerance = 0.01) | ||
expect_equal(get_circum_diam(diamond, "class")$value, 8, tolerance = 0.01) | ||
expect_equal(get_circum_diam(circle, "class")$value, 2) | ||
}) | ||
|
||
testthat::test_that("check vm_p_circum result assertions", { | ||
expect_error(vm_p_circum(vector_patches |> sf::st_centroid(), "class")) | ||
testthat::test_that("check get_circum_diam result assertions", { | ||
expect_error(get_circum_diam(vector_patches |> sf::st_centroid(), "class")) | ||
}) | ||
|
||
testthat::test_that("check vm_p_circum result structure", { | ||
expect_s3_class(vm_p_circum(square, "class"), "tbl_df") | ||
expect_equal(ncol(vm_p_circum(square, "class")), 5) | ||
expect_equal(nrow(vm_p_circum(vector_patches, "class")), nrow(vector_patches)) | ||
expect_true(!is.na(vm_p_circum(squaretxt, "class")$class)) | ||
testthat::test_that("check get_circum_diam result structure", { | ||
expect_s3_class(get_circum_diam(square, "class"), "tbl_df") | ||
expect_equal(ncol(get_circum_diam(square, "class")), 5) | ||
expect_equal(nrow(get_circum_diam(vector_patches, "class")), nrow(vector_patches)) | ||
expect_true(!is.na(get_circum_diam(squaretxt, "class")$class)) | ||
expect_equal( | ||
nrow(vector_patches |> dplyr::inner_join(vm_p_circum(vector_patches, "class", "patch"), by = c("patch" = "id"))), | ||
nrow(vector_patches |> dplyr::inner_join(get_circum_diam(vector_patches, "class", "patch"), by = c("patch" = "id"))), | ||
nrow(vector_patches) | ||
) | ||
expect_true(all( | ||
vector_patches |> dplyr::inner_join(vm_p_circum(vector_patches, "class", "patch"), by = c("patch" = "id")) |> | ||
vector_patches |> dplyr::inner_join(get_circum_diam(vector_patches, "class", "patch"), by = c("patch" = "id")) |> | ||
dplyr::mutate(same_class = class.x == class.y) |> dplyr::pull(same_class) | ||
)) | ||
expect_type(vm_p_circum(square, "class")$class, "character") | ||
expect_type(vm_p_circum(square, "class")$id, "character") | ||
expect_type(vm_p_circum(square, "class")$value, "double") | ||
expect_type(get_circum_diam(square, "class")$class, "character") | ||
expect_type(get_circum_diam(square, "class")$id, "character") | ||
expect_type(get_circum_diam(square, "class")$value, "double") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters