Skip to content

Commit

Permalink
close #89: new install_unit and remove_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchufa2 committed Nov 28, 2020
1 parent 67c608f commit 6a30598
Show file tree
Hide file tree
Showing 19 changed files with 444 additions and 385 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ export(drop_units)
export(install_conversion_constant)
export(install_conversion_offset)
export(install_symbolic_unit)
export(install_unit)
export(load_units_xml)
export(make_unit_label)
export(make_units)
export(mixed_units)
export(remove_symbolic_unit)
export(remove_unit)
export(set_units)
export(ud_are_convertible)
export(unitless)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
* add `load_units_xml` to enable database reloading as well as loading
user-provided unit systems; #254 addressing #243, #244

* add `install_unit` and `remove_unit` for adding/removing custom user-defined
symbols or names, with optional mapping to existing units;
`install_symbolic_unit`, `remove_symbolic_unit`, `install_conversion_constant`,
`install_conversion_offset` are deprecated; #261 addressing #89

* export `ud_are_convertible`; #263 addressing #258 @cregouby

* remove deprecations: `as.units`, `as_cf`, `make_unit`, `parse_unit`; #259
Expand Down
30 changes: 19 additions & 11 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ R_ut_parse <- function(name) {
.Call('_units_R_ut_parse', PACKAGE = 'units', name)
}

R_ut_get_dimensionless_unit_one <- function(name) {
.Call('_units_R_ut_get_dimensionless_unit_one', PACKAGE = 'units', name)
R_ut_get_dimensionless_unit_one <- function() {
.Call('_units_R_ut_get_dimensionless_unit_one', PACKAGE = 'units')
}

R_ut_are_convertible <- function(a, b) {
Expand All @@ -25,16 +25,12 @@ R_convert_doubles <- function(from, to, val) {
.Call('_units_R_convert_doubles', PACKAGE = 'units', from, to, val)
}

R_ut_new_dimensionless_unit <- function(name) {
invisible(.Call('_units_R_ut_new_dimensionless_unit', PACKAGE = 'units', name))
R_ut_new_dimensionless_unit <- function() {
.Call('_units_R_ut_new_dimensionless_unit', PACKAGE = 'units')
}

R_ut_new_base_unit <- function(name) {
invisible(.Call('_units_R_ut_new_base_unit', PACKAGE = 'units', name))
}

R_ut_remove_unit <- function(name) {
invisible(.Call('_units_R_ut_remove_unit', PACKAGE = 'units', name))
R_ut_new_base_unit <- function() {
.Call('_units_R_ut_new_base_unit', PACKAGE = 'units')
}

R_ut_scale <- function(nw, old, d) {
Expand Down Expand Up @@ -86,6 +82,18 @@ R_ut_get_name <- function(ustr) {
}

R_ut_map_name_to_unit <- function(name, inunit) {
.Call('_units_R_ut_map_name_to_unit', PACKAGE = 'units', name, inunit)
invisible(.Call('_units_R_ut_map_name_to_unit', PACKAGE = 'units', name, inunit))
}

R_ut_unmap_name_to_unit <- function(name) {
invisible(.Call('_units_R_ut_unmap_name_to_unit', PACKAGE = 'units', name))
}

R_ut_map_symbol_to_unit <- function(name, inunit) {
invisible(.Call('_units_R_ut_map_symbol_to_unit', PACKAGE = 'units', name, inunit))
}

R_ut_unmap_symbol_to_unit <- function(name) {
invisible(.Call('_units_R_ut_unmap_symbol_to_unit', PACKAGE = 'units', name))
}

2 changes: 1 addition & 1 deletion R/conversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ as.data.frame.units <- function(x, row.names = NULL, optional = FALSE, ...) {

#' @export
as.list.units <- function(x, ...)
mapply(set_units, unclass(x), x, mode="standard", SIMPLIFY=FALSE)
lapply(NextMethod(), set_units, units(x), mode="standard")

#' convert units object into difftime object
#'
Expand Down
Loading

0 comments on commit 6a30598

Please sign in to comment.