Displaying 20 results from an estimated 30000 matches similar to: "stopifnot() suggestion"
2019 Feb 27
1
stopifnot
My points:
- The 'withCallingHandlers' construct that is used in current 'stopifnot' code has no effect. Without it, the warning message is the same. The overridden warning is not raised. The original warning stays.
- Overriding call in error and warning to 'cl.i' doesn't always give better outcome. The original call may be "narrower" than 'cl.i'.
I
2019 Mar 02
1
stopifnot
A private reply by Martin made me realize that I was wrong about
stopifnot(exprs=TRUE) .
It actually works fine. I apologize. What I tried and was failed was
stopifnot(exprs=T) .
Error in exprs[[1]] : object of type 'symbol' is not subsettable
The shortcut
assert <- function(exprs) stopifnot(exprs = exprs)
mentioned in "Warning" section of the documentation similarly fails
2018 Mar 12
3
Bug report: override stopifnot() ?
Hello,
On Mon, Mar 12, 2018 at 09:30:59AM -0700, William Dunlap wrote:
> Why don't you use
> stopifnot( all(m1 == m2) )
> ?
good question. Even though I use
aseert np.all(m1 == m2)
when working with NumPy, I got accustomed to the "handy shortcut"
that I can omit all() with R vectors and matrices.
Then I got trapped with the thing I reported.
On a second thought,
2019 Mar 05
2
stopifnot
Another possible shortcut definition:
assert <- function(exprs)
do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame()))
After thinking again, I propose to use
??? ? ? stop(simpleError(msg, call = if(p <- sys.parent()) sys.call(p)))
- It seems that the call is the call of the frame where stopifnot(...) is evaluated. Because that is the correct context, I
2019 Feb 24
1
stopifnot
>From https://github.com/HenrikBengtsson/Wishlist-for-R/issues/70 :
... and follow up note from 2018-03-15: Ouch... in R-devel, stopifnot() has become yet 4-5 times slower;
...
which is due to a complete rewrite using tryCatch() and withCallingHandlers().
>From https://stat.ethz.ch/pipermail/r-devel/2017-May/074256.html , it seems that 'tryCatch' was used to avoid the following
2017 May 15
2
stopifnot() does not stop at first non-TRUE argument
>>>>> Herv? Pag?s <hpages at fredhutch.org>
>>>>> on Wed, 3 May 2017 12:08:26 -0700 writes:
> On 05/03/2017 12:04 PM, Herv? Pag?s wrote:
>> Not sure why the performance penalty of nonstandard evaluation would
>> be more of a concern here than for something like switch().
> which is actually a primitive. So it seems that
2017 May 15
3
stopifnot() does not stop at first non-TRUE argument
I see in the archives that the attachment cannot pass.
So, here is the code:
8<----
stopifnot_new <- function (...)
{
mc <- match.call()
n <- length(mc)-1
if (n == 0L)
return(invisible())
Dparse <- function(call, cutoff = 60L) {
ch <- deparse(call, width.cutoff = cutoff)
if (length(ch) > 1L)
paste(ch[1L],
2013 Aug 20
7
Extending suggestion for stopifnot
I am using a variant of stopifnot a lot. can I suggest that base R
extends its functionality? I know how to do this for myself. this is
a suggestion for beginners and students. I don't think it would break
anything.
first, I think it would be more useful if it had an optional character
string, so users could write
stopifnot( is.matrix(m), "m is not a matrix" )
this would
2004 May 03
3
R 1.9.0 on AIX, 64-bit
I'm trying to get R 1.9.0 running on AIX 5.1 with the standard AIX
compilers (xlc, xlf) and it is failing 2 of the tests,
test-Reg in reg-tests-1.R like this:
bash-2.05b$ tail -30 reg-tests-1.Rout.fail
[,1] [,2]
[1,] 1 3
[2,] 2 4
[3,] 1 3
[4,] 2 4
> stopifnot(typeof(res) == "list")
> ## were not implemented in 1.8.1
>
>
> ## Date objects with
2019 Mar 05
0
stopifnot
>>>>> Suharto Anggono Suharto Anggono
>>>>> on Tue, 5 Mar 2019 17:29:20 +0000 writes:
> Another possible shortcut definition:
> assert <- function(exprs)
> do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame()))
Thank you. I think this is mostly a matter of taste, but I
liked your version using eval()
2017 May 19
1
stopifnot() does not stop at first non-TRUE argument
While you are fiddling with stopifnot(), please consider changing the form
of the error thrown so that it includes the caller's call. The change
would be from something like
stop( <<the message>> )
to
stop(simpleError( <<the message>>, sys.call(-1)))
For the following code
f <- function(x, y) {
stopifnot(x > y)
x - y
}
g <- function(x,
2019 Mar 02
0
stopifnot
Instead of
if(!is.null(names(cl))) names(cl) <- NULL ,
just
names(cl) <- NULL
looks simpler and the memory usage and speed is not bad in my little experiment.
--------------------------------------------
Subject: Re: [Rd] stopifnot
To: r-devel at r-project.org
Date: Saturday, 2 March, 2019, 3:28 PM
[...]
A revised patch (also with simpler 'cl'):
--- stop.R 2019-02-27
2017 May 18
2
stopifnot() does not stop at first non-TRUE argument
>From an example in http://www.uni-muenster.de/ZIV.BennoSueselbeck/s-html/helpfiles/nargs.html , number of arguments in '...' can be obtained by
(function(...)nargs())(...) .
I now realize that sys.call() doesn't expand '...' when the function is called with '...'. It just returns the call as is. If 'stopifnot' uses sys.call() instead of match.call() , the
2017 May 16
3
stopifnot() does not stop at first non-TRUE argument
switch(i, ...)
extracts 'i'-th argument in '...'. It is like
eval(as.name(paste0("..", i))) .
Just mentioning other things:
- For 'n',
n <- nargs()
can be used.
- sys.call() can be used in place of match.call() .
---------------------------
>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>> on Mon, 15 May 2017 16:28:42
2017 May 15
3
stopifnot() does not stop at first non-TRUE argument
I think Herv?'s idea was just that if switch can evaluate arguments selectively, so can stopifnot(). But switch() is .Primitive, so does it from C.
I think it is almost a no-brainer to implement a sequential stopifnot if dropping to C code is allowed. In R it gets trickier, but how about this:
Stopifnot <- function(...)
{
n <- length(match.call()) - 1
for (i in 1:n)
{
nm
2019 May 30
2
stopifnot
Here is a patch to function 'stopifnot' that adds 'evaluated' argument and makes 'exprs' argument in 'stopifnot' like 'exprs' argument in 'withAutoprint'.
--- stop.R 2019-05-30 14:01:15.282197286 +0000
+++ stop_new.R 2019-05-30 14:01:51.372187466 +0000
@@ -31,7 +31,7 @@
.Internal(stop(call., .makeMessage(..., domain = domain)))
}
2010 Oct 26
1
S4 methods for rbind()
Hello.
I am trying to write an S4 method for rbind(). I have a class of objects
called 'mdm', and I want to be able to rbind() them to one another.
I do not want the method for rbind() to coerce anything to an mdm object.
I want rbind(x1,x2,x1,x2) to work as expected [ie rbind() should take any
number of arguments].
This is what I have so far:
setGeneric(".rbind_pair",
2018 Mar 12
0
Bug report: override stopifnot() ?
Why don't you use
stopifnot( all(m1 == m2) )
?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Mar 12, 2018 at 8:15 AM, Stepan Kasal <kasal at ucw.cz> wrote:
> Hello,
> I stumbled over a problem:
> stopifnot(m1 == m2)
>
> It works with vector or matrix, but does not work for classes from Matrix
> package.
>
> In the source of stopifnot(), there is
2018 Mar 12
2
Bug report: override stopifnot() ?
Hello,
I stumbled over a problem:
stopifnot(m1 == m2)
It works with vector or matrix, but does not work for classes from Matrix package.
In the source of stopifnot(), there is all(m1 == m2) that would just work,
but there is also is.logical(m1 == m2) that id FALSE.
Would it be possible if Matrix package redefined stopifnot() ?
(If there is a bug tracking database for package Matrix, I would
2017 May 03
2
stopifnot() does not stop at first non-TRUE argument
Hi,
It's surprising that stopifnot() keeps evaluating its arguments after
it reaches the first one that is not TRUE:
> stopifnot(3 == 5, as.integer(2^32), a <- 12)
Error: 3 == 5 is not TRUE
In addition: Warning message:
In stopifnot(3 == 5, as.integer(2^32), a <- 12) :
NAs introduced by coercion to integer range
> a
[1] 12
The details section in its man