From osklyar at ebi.ac.uk  Mon Jul 23 11:02:16 2007
From: osklyar at ebi.ac.uk (Oleg Sklyar)
Date: Mon, 23 Jul 2007 10:02:16 +0100
Subject: [Rd] R2.6 bug in arithmetics of S4 classes inherited from 'array',
	or	intended behavior?
Message-ID: <1185181337.6294.29.camel@dirac>

Hi,

I have an S4 class directly derived from 'array' as shown in the code
below (EBImage package of Bioconductor 2.1, devel), it simply contains
array adding a couple of slots:

setClass ("Image",
  representation (colormode="integer", filename="character", 
    compression="character", resolution="numeric", features="list"
  ),
  prototype (colormode= Grayscale, filename="no-name",
compression="JPEG",
    resolution=c(2.5e+6, 2.5e+6), features=list()
  ),
  contains = "array"
)

No mathematical/arithmetical routines have been redefined for the class
and this is what I was getting since R2.0, sum of two objects of class
Image is Image again:

version.string R version 2.5.1 (2007-06-27):
> library(EBImage)
> a <- Image(0, c(2,2))
> class(a+a)
[1] "Image"
attr(,"package")
[1] "EBImage"

The same stands for 

version.string R version 2.6.0 Under development (unstable) (2007-07-11
r42199)
> library(EBImage)
> a <- Image(0, c(2,2))
> class(a+a)
[1] "Image"
attr(,"package")
[1] "EBImage"

Now, in the yesterday's revision of R2.6 I get the following:

version.string R version 2.6.0 Under development (unstable) (2007-07-21
r42284)

> library(EBImage)
> a <- Image(0, c(2,2))
> class(a+a)
[1] "array"

Is this the intended behavior to fall back to the base class (same for
*,/,-)? If yes, could someone point me to the following two things: what
are the reasons behind and WHAT operators and functions have been
affected -- I will need to redefine all those then. Moreover, it is not
consistent:

> class(a*2)
[1] "Image"
attr(,"package")
[1] "EBImage"
> class(2*a)
[1] "Image"
attr(,"package")
[1] "EBImage"


Unfortunately, I do not have R versions installed between revisions
42199 and 42284, so I cannot narrow down to the particular revision. 

Thanks in advance,
Oleg

-- 
Dr. Oleg Sklyar * EBI-EMBL, Cambridge CB10 1SD, UK * +441223493366



[Rd] R2.6 bug in arithmetics of S4 classes inherited from 'array', or intended behavior?
Oleg Sklyar