ropensci / EML

Ecological Metadata Language interface for R: synthesis and integration of heterogenous data
https://docs.ropensci.org/EML
Other
97 stars 33 forks source link

set_attributes(): standardUnit interpreted as customUnit #311

Closed clnsmth closed 4 years ago

clnsmth commented 4 years ago

Good day @cboettig @amoeba !

In master (2.0.3) the standardUnits object created in standardUnits.R and saved to sysdata.rda appears to be inaccurate. In this version, the standard unit "percent" is incorrectly interpreted as a custom unit.

>   r <- EML::set_attributes(
     data.frame(
       attributeName = "soilmoisture", 
       formatString = "",
       unit = "percent",
       numberType = "real",
       attributeDefinition = "measurement of soil moisture",
       stringsAsFactors = FALSE),
     col_classes = "numeric")
Warning message:
In set_attribute(attributes[i, ], factors = factors, missingValues = missingValues) :
  Unit 'percent' is not a recognized standard unit; treating as custom unit. Please be sure you also define a custom unit in your EML record, or replace with a recognized standard unit. See set_unitList() for details.
>

I've refreshed the standardUnits object and the standard unit "percent" is now correctly interpreted.

>   r <- EML::set_attributes(
     data.frame(
       attributeName = "soilmoisture", 
       formatString = "",
       unit = "percent",
       numberType = "real",
       attributeDefinition = "measurement of soil moisture",
       stringsAsFactors = FALSE),
     col_classes = "numeric")
>

However, this change broke a number of tests in the get_unit_id test suite. This seems to have originated from a missing udunits_units object. I formally created and saved this object in standardUnits.R along side the standardUnits object. Furthermore, I updated the deprecated devtools::use_data() with usethis::use_data() and set the argument overwrite = TRUE.

A PR is on the way.

My session info:

R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] EML_2.0.3      testthat_2.3.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        pillar_1.4.6      compiler_3.6.3    prettyunits_1.1.1
 [5] remotes_2.1.1     tools_3.6.3       emld_0.5.0        digest_0.6.25    
 [9] pkgbuild_1.0.8    pkgload_1.0.2     uuid_0.1-4        tibble_3.0.3     
[13] lifecycle_0.2.0   evaluate_0.14     jsonlite_1.7.0    memoise_1.1.0    
[17] pkgconfig_2.0.3   rlang_0.4.7       cli_2.0.2         rstudioapi_0.11  
[21] curl_4.3          yaml_2.2.1        xfun_0.15         dplyr_1.0.0      
[25] knitr_1.29        withr_2.2.0       jqr_1.1.0         xml2_1.3.2       
[29] generics_0.0.2    vctrs_0.3.1       desc_1.2.0        fs_1.4.1         
[33] devtools_2.3.0    tidyselect_1.1.0  rprojroot_1.3-2   jsonld_2.2       
[37] glue_1.4.1        R6_2.4.1          processx_3.4.2    fansi_0.4.1      
[41] rmarkdown_2.3     sessioninfo_1.1.1 purrr_0.3.4       callr_3.4.3      
[45] magrittr_1.5      htmltools_0.5.0   backports_1.1.7   ps_1.3.3         
[49] ellipsis_0.3.1    usethis_1.6.1     assertthat_0.2.1  V8_3.2.0         
[53] lazyeval_0.2.2    crayon_1.3.4    
amoeba commented 4 years ago

Thanks @clnsmth !