Re: [Rd] selectMethod() can fail to find methods in situations of multiple dispatch

2019-03-21 Thread Pages, Herve
Good to know about the method?foo("numeric") syntax. And apparently it knows 
about inheritance! Thanks for mentioning that. I see it's documented in ?`?`... 
Darn! How could I miss it for so many years!

Note however that this syntax doesn't seem to work in case of "ANY" truncation 
so I won't be able to fully adopt this syntax for now:

> library(Matrix)

> showMethods("colSums")
Function: colSums (package base)
x="ANY"
x="CsparseMatrix"
x="ddenseMatrix"
x="denseMatrix"
x="dgCMatrix"
x="dgeMatrix"
x="diagonalMatrix"
x="igCMatrix"
x="indMatrix"
x="lgCMatrix"
x="ngCMatrix"
x="RsparseMatrix"
x="TsparseMatrix"

> method?colSums("dgCMatrix")
Error in .helpForCall(topicExpr, parent.frame(), FALSE) :
  no documentation for function ‘colSums’ and signature ‘x = "dgCMatrix", na.rm 
= "logical", dims = "numeric"’
In addition: Warning message:
In .helpForCall(topicExpr, parent.frame(), FALSE) :
  no method defined for function ‘colSums’ and signature ‘x = "dgCMatrix", 
na.rm = "logical", dims = "numeric"’

But maybe it uses selectMethod() behind the seen so will work once 
selectMethod() gets fixed?

Thanks,

H.


On 3/21/19 22:05, Michael Lawrence wrote:
Agreed but I'm not sure we want users accessing documentation with those types 
of aliases. One option is the method?foo("numeric") syntax.

On Thu, Mar 21, 2019 at 9:52 PM Pages, Herve 
mailto:hpa...@fredhutch.org>> wrote:

Fine with me as long as eliminating the inconveniences associated with it can 
be put on the roadmap. The alias instability and the fact that the user has no 
way to know if s/he should do ?`foo,numeric-method` or 
?`foo,numeric,ANY-method` to find the method has been a long-standing problem.

H.

On 3/21/19 21:29, Michael Lawrence wrote:
If we started over, I'd try to avoid this sort of complexity, but "ANY" 
truncation has been happening since at least 2003.

> matchSignature(c("numeric", "ANY"), foo)
x
"numeric"

So I'm not sure we want to mess with it.

Michael

On Thu, Mar 21, 2019 at 8:14 PM Pages, Herve 
mailto:hpa...@fredhutch.org>> wrote:

Hi Michael,

Thanks for looking into this. I suspect that truncation of ANY suffixes from 
method signatures is also the culprit behind the sudden breakage of aliases of 
the form \alias{foo,numeric-method} when a method without the ANY suffix in its 
signature gets added to the ecosystem. See my post about this to the Bioc-devel 
mailing list a couple 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 
mailto:hpa...@fredhutch.org>> wrote:
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, logical

Adding an arbitrary method that doesn't have ANY in the signature "fixes" 
selectMethod():

  setMethod("foo", c("complex", "integer"),
function(x, y) cat("I'm the foo#complex#integer method\n")
  )

Then:

  > selectMethod("foo", c("numeric", "logical"))
  Method Definition:

  function (x, y)
  cat("I'm the foo#numeric#ANY method\n")

  Signatures:
x y
  target  "numeric" "logical"
  defined "numeric" "ANY"


Thanks,

H.


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: 
hpa...@fredhutch.org>
Phone:  (206) 667-5791
Fax:(206) 667-1319


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences

Re: [Rd] selectMethod() can fail to find methods in situations of multiple dispatch

2019-03-21 Thread Michael Lawrence via R-devel
Agreed but I'm not sure we want users accessing documentation with those
types of aliases. One option is the method?foo("numeric") syntax.

On Thu, Mar 21, 2019 at 9:52 PM Pages, Herve  wrote:

> Fine with me as long as eliminating the inconveniences associated with it
> can be put on the roadmap. The alias instability and the fact that the user
> has no way to know if s/he should do ?`foo,numeric-method` or
> ?`foo,numeric,ANY-method` to find the method has been a long-standing
> problem.
>
> H.
> On 3/21/19 21:29, Michael Lawrence wrote:
>
> If we started over, I'd try to avoid this sort of complexity, but "ANY"
> truncation has been happening since at least 2003.
>
> > matchSignature(c("numeric", "ANY"), foo)
> x
> "numeric"
>
> So I'm not sure we want to mess with it.
>
> Michael
>
> On Thu, Mar 21, 2019 at 8:14 PM Pages, Herve  wrote:
>
>> Hi Michael,
>>
>> Thanks for looking into this. I suspect that truncation of ANY suffixes
>> from method signatures is also the culprit behind the sudden breakage of
>> aliases of the form \alias{foo,numeric-method} when a method without the
>> ANY suffix in its signature gets added to the ecosystem. See my post about
>> this to the Bioc-devel mailing list a couple 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 
>> wrote:
>>
>>> 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, logical
>>>
>>> Adding an arbitrary method that doesn't have ANY in the signature
>>> "fixes" selectMethod():
>>>
>>>   setMethod("foo", c("complex", "integer"),
>>> function(x, y) cat("I'm the foo#complex#integer method\n")
>>>   )
>>>
>>> Then:
>>>
>>>   > selectMethod("foo", c("numeric", "logical"))
>>>   Method Definition:
>>>
>>>   function (x, y)
>>>   cat("I'm the foo#numeric#ANY method\n")
>>>
>>>   Signatures:
>>> x y
>>>   target  "numeric" "logical"
>>>   defined "numeric" "ANY"
>>>
>>>
>>> Thanks,
>>>
>>> H.
>>>
>>>
>>> --
>>> Hervé Pagès
>>>
>>> Program in Computational Biology
>>> Division of Public Health Sciences
>>> Fred Hutchinson Cancer Research Center
>>> 1100 Fairview Ave. N, M1-B514
>>> P.O. Box 19024
>>> Seattle, WA 98109-1024
>>>
>>> E-mail: hpa...@fredhutch.org
>>> Phone:  (206) 667-5791
>>> Fax:(206) 667-1319
>>>
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-devel@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>> 
>>>
>> --
>> Hervé Pagès
>>
>> Program in Computational Biology
>> Division of Public Health Sciences
>> Fred Hutchinson Cancer Research Center
>> 1100 Fairview Ave. N, M1-B514
>> P.O. Box 19024
>> Seattle, WA 98109-1024
>>
>> E-mail: hpa...@fredhutch.org
>> Phone:  (206) 667-5791
>> Fax:(206) 667-1319
>>
>> --
> Hervé Pagès
>
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
>
> E-mail: hpa...@fredhutch.org
> Phone:  (206) 667-5791
> Fax:(206) 667-1319
>
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] selectMethod() can fail to find methods in situations of multiple dispatch

2019-03-21 Thread Pages, Herve
Fine with me as long as eliminating the inconveniences associated with it can 
be put on the roadmap. The alias instability and the fact that the user has no 
way to know if s/he should do ?`foo,numeric-method` or 
?`foo,numeric,ANY-method` to find the method has been a long-standing problem.

H.

On 3/21/19 21:29, Michael Lawrence wrote:
If we started over, I'd try to avoid this sort of complexity, but "ANY" 
truncation has been happening since at least 2003.

> matchSignature(c("numeric", "ANY"), foo)
x
"numeric"

So I'm not sure we want to mess with it.

Michael

On Thu, Mar 21, 2019 at 8:14 PM Pages, Herve 
mailto:hpa...@fredhutch.org>> wrote:

Hi Michael,

Thanks for looking into this. I suspect that truncation of ANY suffixes from 
method signatures is also the culprit behind the sudden breakage of aliases of 
the form \alias{foo,numeric-method} when a method without the ANY suffix in its 
signature gets added to the ecosystem. See my post about this to the Bioc-devel 
mailing list a couple 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 
mailto:hpa...@fredhutch.org>> wrote:
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, logical

Adding an arbitrary method that doesn't have ANY in the signature "fixes" 
selectMethod():

  setMethod("foo", c("complex", "integer"),
function(x, y) cat("I'm the foo#complex#integer method\n")
  )

Then:

  > selectMethod("foo", c("numeric", "logical"))
  Method Definition:

  function (x, y)
  cat("I'm the foo#numeric#ANY method\n")

  Signatures:
x y
  target  "numeric" "logical"
  defined "numeric" "ANY"


Thanks,

H.


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: 
hpa...@fredhutch.org>
Phone:  (206) 667-5791
Fax:(206) 667-1319


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] selectMethod() can fail to find methods in situations of multiple dispatch

2019-03-21 Thread Michael Lawrence via R-devel
If we started over, I'd try to avoid this sort of complexity, but "ANY"
truncation has been happening since at least 2003.

> matchSignature(c("numeric", "ANY"), foo)
x
"numeric"

So I'm not sure we want to mess with it.

Michael

On Thu, Mar 21, 2019 at 8:14 PM Pages, Herve  wrote:

> Hi Michael,
>
> Thanks for looking into this. I suspect that truncation of ANY suffixes
> from method signatures is also the culprit behind the sudden breakage of
> aliases of the form \alias{foo,numeric-method} when a method without the
> ANY suffix in its signature gets added to the ecosystem. See my post about
> this to the Bioc-devel mailing list a couple 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  wrote:
>
>> 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, logical
>>
>> Adding an arbitrary method that doesn't have ANY in the signature "fixes"
>> selectMethod():
>>
>>   setMethod("foo", c("complex", "integer"),
>> function(x, y) cat("I'm the foo#complex#integer method\n")
>>   )
>>
>> Then:
>>
>>   > selectMethod("foo", c("numeric", "logical"))
>>   Method Definition:
>>
>>   function (x, y)
>>   cat("I'm the foo#numeric#ANY method\n")
>>
>>   Signatures:
>> x y
>>   target  "numeric" "logical"
>>   defined "numeric" "ANY"
>>
>>
>> Thanks,
>>
>> H.
>>
>>
>> --
>> Hervé Pagès
>>
>> Program in Computational Biology
>> Division of Public Health Sciences
>> Fred Hutchinson Cancer Research Center
>> 1100 Fairview Ave. N, M1-B514
>> P.O. Box 19024
>> Seattle, WA 98109-1024
>>
>> E-mail: hpa...@fredhutch.org
>> Phone:  (206) 667-5791
>> Fax:(206) 667-1319
>>
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
>>
> --
> Hervé Pagès
>
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
>
> E-mail: hpa...@fredhutch.org
> Phone:  (206) 667-5791
> Fax:(206) 667-1319
>
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] selectMethod() can fail to find methods in situations of multiple dispatch

2019-03-21 Thread Pages, Herve
Hi Michael,

Thanks for looking into this. I suspect that truncation of ANY suffixes from 
method signatures is also the culprit behind the sudden breakage of aliases of 
the form \alias{foo,numeric-method} when a method without the ANY suffix in its 
signature gets added to the ecosystem. See my post about this to the Bioc-devel 
mailing list a couple 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 
mailto:hpa...@fredhutch.org>> wrote:
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, logical

Adding an arbitrary method that doesn't have ANY in the signature "fixes" 
selectMethod():

  setMethod("foo", c("complex", "integer"),
function(x, y) cat("I'm the foo#complex#integer method\n")
  )

Then:

  > selectMethod("foo", c("numeric", "logical"))
  Method Definition:

  function (x, y)
  cat("I'm the foo#numeric#ANY method\n")

  Signatures:
x y
  target  "numeric" "logical"
  defined "numeric" "ANY"


Thanks,

H.


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: 
hpa...@fredhutch.org>
Phone:  (206) 667-5791
Fax:(206) 667-1319


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] prettyNum digits=0 not compatible with scientific notation

2019-03-21 Thread Robert McGehee
R developers,
Seems I get a bad result ("%#4.0-1e" in particular) when trying to use 
prettyNum digits=0 with scientific notation. I tried on both my Linux box and 
on an online R evaluator and saw the same problem, so it's not limited to my 
box at least. I see the problem in both R 3.5.3 and R 3.3.2.

options(scipen=-100)
prettyNum(1, digits=0)
[1] "%#4.0-1e"
prettyNum(2, digits=0)
[1] "%#4.0-1e"
prettyNum(1, digits=0, scientific=FALSE) # Works
[1] "1"
prettyNum(1:2, digits=0) # Works
[1] "1" "2"
prettyNum(c(1.1, 2.1), digits=0)
[1] "%#4.0-1e" "%#4.0-1e"
prettyNum(c(1.1, 2.1), digits=1) # Works
[1] "1e+00" "2e+00"

> R.version
   _   
platform   x86_64-pc-linux-gnu 
arch   x86_64  
os linux-gnu   
system x86_64, linux-gnu   
status 
major  3   
minor  5.3 
year   2019
month  03  
day11  
svn rev76217   
language   R   
version.string R version 3.5.3 (2019-03-11)
nickname   Great Truth 

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel