forked from PecanProject/pecan
-
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.
- Loading branch information
Showing
6 changed files
with
61 additions
and
0 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
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 |
---|---|---|
|
@@ -21,6 +21,8 @@ Authors@R: c(person("Mike", "Dietze", role = c("aut"), | |
email = "[email protected]"), | ||
person("Chris", "Black", role = c("aut"), | ||
email = "[email protected]"), | ||
person("Tanishq", "Jain", role = c("aut"), | ||
email = "[email protected]"), | ||
person("University of Illinois, NCSA", role = c("cph"))) | ||
Description: The Predictive Ecosystem Carbon Analyzer | ||
(PEcAn) is a scientific workflow management tool that | ||
|
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
##' Check whether a unit string is parseable | ||
##' | ||
##' Function will replace the now-unmaintained `udunits2::ud.is.parseable` | ||
##' @author Tanishq Jain | ||
##' | ||
##' @param u1 A character string representing a type of units | ||
##' | ||
##' @return TRUE if the units is parseable, FALSE otherwise. | ||
##' @export | ||
unit_is_parseable <- function(u1){ | ||
tryCatch({ | ||
if(units::as_units(u1)) | ||
return(TRUE) | ||
}, | ||
error = function(e) FALSE | ||
) | ||
} # unit_is_parseable |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
test_that("parseable unit", { | ||
expect_equal(unit_is_parseable("miles"), TRUE) | ||
expect_equal(unit_is_parseable(" K "), TRUE) | ||
expect_equal(unit_is_parseable("10cm"), TRUE) | ||
expect_equal(unit_is_parseable("m/s"), TRUE) | ||
expect_equal(unit_is_parseable("kg"), TRUE) | ||
}) | ||
|
||
test_that("Non-paresable unit", { | ||
expect_equal(unit_is_parseable("fake"), FALSE) | ||
expect_equal(unit_is_parseable("gk"), FALSE) | ||
expect_equal(unit_is_parseable(NULL), FALSE) | ||
expect_equal(unit_is_parseable("Not parseable"), FALSE) | ||
expect_equal(unit_is_parseable("Loading"), FALSE) | ||
}) | ||
|
||
# This differ from `udunits2::ud.is.parseable` | ||
#test_that("incompatiable unit to parse", { | ||
# expect_error(unit_is_parseable("")) | ||
#}) |