search for: selectmethod

Displaying 20 results from an estimated 87 matches for "selectmethod".

2019 Mar 14
2
selectMethod() can fail to find methods in situations of multiple dispatch
Here is an example: setGeneric("foo", function(x, y) standardGeneric("foo")) setMethod("foo", c("numeric", "ANY"), function(x, y) cat("I'm the foo#numeric#ANY method\n") ) Dispatch works as expected but selectMethod() fails to find the method: > foo(1, TRUE) I'm the foo#numeric#ANY method > selectMethod("foo", c("numeric", "logical")) Error in selectMethod("foo", c("numeric", "logical")) : no method found for signature numeric...
2019 Mar 22
2
selectMethod() can fail to find methods in situations of multiple dispatch
...of months ago: https://stat.ethz.ch/pipermail/bioc-devel/2019-January/014603.html So overall isn't this truncation more trouble than it's worth? H. On 3/19/19 10:12, Michael Lawrence wrote: This is due to the intentional truncation of ANY suffixes from method signatures. I've hacked selectMethod() to be robust to that and will commit soon. Thanks for the report. Michael On Thu, Mar 14, 2019 at 9:32 AM Pages, Herve <hpages at fredhutch.org<mailto:hpages at fredhutch.org>> wrote: Here is an example: setGeneric("foo", function(x, y) standardGeneric("foo"))...
2019 Mar 19
0
selectMethod() can fail to find methods in situations of multiple dispatch
This is due to the intentional truncation of ANY suffixes from method signatures. I've hacked selectMethod() to be robust to that and will commit soon. Thanks for the report. Michael On Thu, Mar 14, 2019 at 9:32 AM Pages, Herve <hpages at fredhutch.org> wrote: > Here is an example: > > setGeneric("foo", function(x, y) standardGeneric("foo")) > > setMethod(...
2019 Mar 22
2
selectMethod() can fail to find methods in situations of multiple dispatch
...iyz1xl8WY9gONjtL65IxE&s=R9Hi4Rm4nk-izYC8vDCj0NiuFdUMG4vZVbdQgsvxkDM&e=> So overall isn't this truncation more trouble than it's worth? H. On 3/19/19 10:12, Michael Lawrence wrote: This is due to the intentional truncation of ANY suffixes from method signatures. I've hacked selectMethod() to be robust to that and will commit soon. Thanks for the report. Michael On Thu, Mar 14, 2019 at 9:32 AM Pages, Herve <hpages at fredhutch.org<mailto:hpages at fredhutch.org>> wrote: Here is an example: setGeneric("foo", function(x, y) standardGeneric("foo"))...
2019 Mar 22
0
selectMethod() can fail to find methods in situations of multiple dispatch
...pipermail/bioc-devel/2019-January/014603.html > > So overall isn't this truncation more trouble than it's worth? > > H. > On 3/19/19 10:12, Michael Lawrence wrote: > > This is due to the intentional truncation of ANY suffixes from method > signatures. I've hacked selectMethod() to be robust to that and will commit > soon. Thanks for the report. > > Michael > > On Thu, Mar 14, 2019 at 9:32 AM Pages, Herve <hpages at fredhutch.org> wrote: > >> Here is an example: >> >> setGeneric("foo", function(x, y) standardGeneric(&...
2012 Aug 03
1
Interaction between callNextMethod() and selectMethod()
...n(x, ...) t(callNextMethod())) Creating a generic function for ?as.matrix? from package ?base? in the global environment [1] "as.matrix" > a <- new("A", 1:3) > as.matrix(a) [,1] [,2] [,3] [1,] 1 2 3 Everything fine so far. But: > selectMethod("as.matrix", "A")(a) Error in callNextMethod() : c("a call to callNextMethod() appears in a call to \"selectMethod\", but the call does not seem to come from either a generic function or another 'callNextMethod'", "a call to callNextMe...
2019 Mar 22
0
selectMethod() can fail to find methods in situations of multiple dispatch
...DM&e=> >> >> So overall isn't this truncation more trouble than it's worth? >> >> H. >> On 3/19/19 10:12, Michael Lawrence wrote: >> >> This is due to the intentional truncation of ANY suffixes from method >> signatures. I've hacked selectMethod() to be robust to that and will commit >> soon. Thanks for the report. >> >> Michael >> >> On Thu, Mar 14, 2019 at 9:32 AM Pages, Herve <hpages at fredhutch.org> >> wrote: >> >>> Here is an example: >>> >>> setGeneric(&quo...
2007 May 01
1
Possible problem with S4 dispatch
...y to reproduce case, and I won't be surprised if the root cause is a fault in my code's use of name spaces or some such. The error I'm seeing is one in which the desired method is not found. What worries me in terms of my expectations of how to debug the problem is that showMethods and selectMethod both find the method. Here is an example browser session: ## Input 1, a character vector Browse[1]> gN[1:3] [1] "1005_at" "1007_s_at" "1008_f_at" ## Input 2, an object of class AtomicAnnMap (subclass of AnnMap) Browse[1]> class(LLe)...
2010 Mar 31
1
as(1:4, "numeric") versus as.numeric(1:4, "numeric")
...is.numeric(1:4) [1] TRUE > is.numeric(as(1:4, "numeric")) [1] TRUE However, 'as(1:4, "numeric")' is inconsistent with > class(as.numeric(1:4)) [1] "numeric" And, even more confusing, if you look at the coerce,ANY,numeric method: > selectMethod("coerce", c("integer", "numeric")) Method Definition: function (from, to, strict = TRUE) { value <- as.numeric(from) if (strict) attributes(value) <- NULL value } <environment: namespace:methods> Signatures:...
2011 Jun 01
1
Overloading S4 methods
..., using setGeneric("plot", useAsDefault = plot) and with importFrom('graphics', 'plot') and exportMethods('plot') in the NAMESPACE file of pkg A. I then proceed to define a method for signature c('myS4class', 'missing'). This works as expected: selectMethod('plot', c('myS4class', 'missing')) returns the newly defined method, and the method gets called when invoked. Another pkg, B, wishes to overload this and redefines the method for the same signature. A method is defined for c('myS4class', 'missing'), and expo...
2012 Oct 01
1
False positive note about ambiguous dispatch
...A") Note: Method with signature ?numeric#A? chosen for function ?coerce?, target signature ?integer#A?. "ANY#A" would also be valid An object of class "A" Slot "stuff": [1] 6+0i First thing is that the note is in contradiction with the output of selectMethod (seems like it's the method with signature "ANY#A" that was chosen, not the method with signature "numeric#A"): > selectMethod("coerce", c("integer", "A")) Method Definition: function (from, to = "A", strict = TRUE) ne...
2024 May 14
0
Support for as(x, "raw")
...? no method or default for coercing ?integer? to ?raw? Even though as.raw(1L) works: ??? > as.raw(1L) ??? [1] 01 Is there any particular reason for that or would it be reasonable to define a coerce() method from ANY to raw like it's been done for all the other vector types: ??? > selectMethod(coerce, c("ANY", "logical")) ??? Method Definition: ??? function (from, to, strict = TRUE) ??? { ? ? ? ? value <- as.logical(from) ? ? ? ? if (strict) ?? ? ?? ??? attributes(value) <- NULL ? ? ? ? value ??? } ??? <environment: namespace:methods> ??? Signatu...
2005 Apr 20
1
callNextMethod()
...oc variable outside the signature which have different default values for each class. Each method calls callNextMethod() to populate the slots which it has in common with the previous class and then some additional code to populate the new slots in the class. Before writing each new method the selectMethod() function correctly identifies the method which I would like to call from the callNextMethod() function. But after 3-4 levels of nesting the method seem unable to identify the correct next method and returns nothing but continues without error. I'm sorry, but I couldn't reproduce the...
2013 Jul 02
2
cache most-recent dispatch
...tch can be very slow. Would it be reasonable to cache the most recent dispatch, anticipating the next invocation will be on the same type? This would be very helpful in loops. fun0 <- function(x) sapply(x, paste, collapse="+") fun1 <- function(x) { paste <- selectMethod(paste, class(x[[1]])) sapply(x, paste, collapse="+") } lst <- split(rep(LETTERS, 100), rep(1:1300, 2)) library(microbenchmark) microbenchmark(fun0(lst), times=10) ## Unit: milliseconds ## expr min lq median uq max neval ## fun0...
2003 Jul 26
2
How to make "<-" generic?
...Method(paste(f, "<-", sep = ""), ...) > ## and > isGeneric("<-") [1] TRUE > a <- new("A") > b <- new("B") > a <- b > a An object of class "B" Slot "x": numeric(0) > ## should be a ? > ## but selectMethod(...) works correct > selectMethod("<-",c("A","B")) Method Definition (Class "MethodDefinition"): function(x,value) { print("myAssign.default"); return(x); } Signatures: x value target "A" "B" defined "A&qu...
2014 Feb 19
0
dispatch on "c" method when passing named arguments
...function(aa) new("B", aa=aa)) Then: > do.call("c", list_of_B_objects) $chr1 An object of class "B" Slot "aa": [1] 1 2 3 $chr2 An object of class "B" Slot "aa": [1] 11 12 ==> dispatch failed! Note that selectMethod() is not helping the user understand what's going on: > selectMethod("c", "B") Method Definition: function (x, ..., recursive = FALSE) { if (missing(x)) { objects <- list(...) x <- objects[[1L]] } else { object...
2009 May 18
1
S4 method dispatch and namespaces: why is default method selected
...ixmap'. Why? As far as I understand the documentation and section 10.6 of "Software for Data Analysis" the default method should never be selected as far as there are other candidates. And there seems to be other candidates, and they seem to be properly selected if checked using 'selectMethod' (this is from results from package tests): > showMethods("plot") Function: plot (package graphics) x="ANY", y="ANY" x="myclass", y="missing" x="pixmap", y="ANY" > selectMethod("plot", signature(x="...
2007 Apr 12
3
Method dispatch for print() in package its
Dear all, in the package its the print() method does not seem to correctly work in all circumstances: > selectMethod(print, "its") Method Definition: function (x, ...) { print(x@.Data <mailto:x@.Data> , ...) } <environment: namespace:its> Signatures: x target "its" defined "its" > fundPME.lst[[1]]$irr An object of class "its"...
2006 Dec 11
1
Wondering about methods (selecting a less specialized method)
...A and a method Foo with the signature (X,A,Y) and I'd like to implement Foo with the signature (X,B,Y) such that it calls Foo_(X,A,Y) and then does "other stuff." This gets a bit complicated with multiple inheritance but at the moment the best I can think to do is an explicit call to selectMethod.
2009 Nov 25
1
group generics
...) } ) setClass("B", representation=representation(xb="numeric"), contains=c("A") ) setMethod("Arith", signature(e1="numeric", e2="B"), function(e1, e2) { # the next line does not work right v <- selectMethod("callGeneric", signature=c("numeric", "A"))(e1, e2) print(v) new("B", v, xb=e1*e2 at xb) } ) Results: > t1 <- new("B", new("A", xa=4), xb=2) > t1 An object of class ?B? Slot "xb": [1] 2 Slot "xa": [1] 4...