Skip to content

Commit

Permalink
Several performance improvements (3) (#393)
Browse files Browse the repository at this point in the history
* fix regression #389

* update NEWS
  • Loading branch information
Enchufa2 authored Feb 14, 2025
1 parent f056aee commit 52a9227
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

* Add support for `brew` path discovery in macOS; #384

* Several performance improvements; #387, #388 addressing #386
* Several performance improvements; #387, #388, #393 addressing #386, #389

# version 0.8-5

Expand Down
3 changes: 2 additions & 1 deletion R/udunits.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ ud_are_convertible = function(x, y) {

ud_char <- function(x) {
if (is.character(x)) return(x)
res <- paste(x$numerator, collapse=" ")
res <- if (length(x$numerator))
paste(x$numerator, collapse=" ") else "1"
if (length(x$denominator))
res <- paste0(res, " (", paste(x$denominator, collapse=" "), ")-1")
res
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ test_that("We can concatenate units if their units can be converted", {
y <- set_units(y, units(as_units("m")), mode = "standard")
expect_equal(y, z[1:4 + 4])
expect_equal(y, z[1:4 + 12])

x <- 1:4 * as_units("Hz")
y <- 5:8 * as_units("1/min")
z <- c(x, y)

expect_equal(length(z), length(x) + length(y))
expect_equal(as.character(units(z)), "Hz")
expect_equal(x, z[1:4])
y <- set_units(y, units(as_units("Hz")), mode = "standard")
expect_equal(y, z[1:4 + 4])
})

test_that("We can use diff on a units object", {
Expand Down

0 comments on commit 52a9227

Please sign in to comment.