Skip to content

Commit

Permalink
Fix bug, bump to v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBinette committed Dec 24, 2024
1 parent c0de371 commit b2e3727
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: assert
Title: Validate Function Arguments
Version: 1.0.1
Version: 1.1.0
Authors@R:
person(given = "Olivier",
family = "Binette",
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# assert 1.1.0
- Fix bug with "Run Examples" in help environment.

# assert 1.0.1
- Improved performance.

Expand Down
2 changes: 1 addition & 1 deletion R/assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ assert <- function(...,
else warning(c("\n", msg), call. = FALSE)
} else {
msg <- c("in ",
eval(quote(match.call()), parent.frame()),
eval(quote(sys.call()), parent.frame()),
"\n",
msg)
if (stop) stop(msg, call. = FALSE)
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# :white_check_mark: assert
# :eyes: assert

<!-- badges: start -->

[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/assert)](https://cran.r-project.org/package=assert)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/assert)](https://cran.r-project.org/package=assert)
[![Build
Status](https://travis-ci.org/OlivierBinette/assert.svg?branch=master)](https://travis-ci.org/OlivierBinette/assert)
![R-CMD-check](https://github.com/OlivierBinette/assert/workflows/R-CMD-check/badge.svg)
<!-- badges: end -->

Lightweight validation tool for checking function arguments and data
analysis scripts. This is an alternative to stopifnot() from the ‘base’
package and to assert\_that() from the ‘assertthat’ package. It provides
package and to assert_that() from the ‘assertthat’ package. It provides
more informative error messages and facilitates debugging.

<img src="gif.gif" width="700">
Expand Down Expand Up @@ -78,9 +78,9 @@ rmultinorm <- function(k, mu, sigma) {
mu <- c(0,10)
sigma <- matrix(c(2,1,1,2), nrow=2)
rmultinorm(3, mu, sigma)
#> [,1] [,2] [,3]
#> [1,] -2.246757 -1.424890 -0.9528532
#> [2,] 7.941552 9.283195 10.4848747
#> [,1] [,2] [,3]
#> [1,] -0.02311083 -1.060765 1.00757
#> [2,] 12.94321538 9.129731 14.52424
```

``` r
Expand Down Expand Up @@ -112,15 +112,16 @@ potential errors). `assertthat::assert_that` has the most overhead.

``` r
library(assertthat)
#> Warning: package 'assertthat' was built under R version 4.4.2

bench::mark(assert(TRUE),
assert_that(TRUE),
stopifnot(TRUE),
check=FALSE)
#> # A tibble: 3 x 6
#> # A tibble: 3 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 assert(TRUE) 14.88µs 17.5µs 55463. 0B 55.5
#> 2 assert_that(TRUE) 29.05µs 32µs 29553. 26.9KB 8.87
#> 3 stopifnot(TRUE) 2.72µs 3µs 269977. 0B 0
#> 1 assert(TRUE) 6.5µs 7.2µs 118811. 0B 23.8
#> 2 assert_that(TRUE) 12.3µs 13.2µs 70165. 26.9KB 21.1
#> 3 stopifnot(TRUE) 1.2µs 1.3µs 702484. 0B 0
```

0 comments on commit b2e3727

Please sign in to comment.