Re: [R-pkg-devel] Error creating union class: object ‘.__C__compMatrix’ not found

2020-05-18 Thread Duncan Murdoch

On 29/04/2020 1:16 p.m., renozao wrote:

Thank you Martin,

Looks like the mMatrix class defined in Matrix is not exported in 3.6.3, maybe 
it is now exported in the current R-devel.


Matrix doesn't have the same versions as R:  it's a recommended package, 
not a base package.  It can be updated independently of R.  The current 
version on CRAN is 1.2-18, but the R-forge version is 1.3-0.  Neither 
one exports mMatrix.


Duncan Murdoch



In this case I'd rather use a conditional import and definition.
I'll try that route.

Bests,
Renaud

Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐
On Saturday, April 18, 2020 12:36 PM, Martin Maechler 
 wrote:


renozao
on Wed, 8 Apr 2020 16:19:59 + writes:



Thank you William for the reproducible example.


 > Currently I using the following (same as in William's example):

 > setClassUnion("mMatrix", c("Matrix", "matrix"))



Martin, are the changes made in the union class handling affecting the way we 
should declare them?



Thank you.



Bests,


 > Renaud


Thank you, Renaud, and Bill Dunlap.

There is obviously a bit of a problem there, but it may well be
"only" a problem in error handling.

As Bill's trace(get, ..) shows, R tries to get
"#HAS_DUPLICATE_CLASS_NAMES" which is indeed an indication of the problem:

You are trying to REdefine a class union that already exists
identically in the Matrix package:
In the R-forge development version of 'Matrix', it is
line 717 of Matrix/R/AllClass.R (and that will be close also
in the CRAN version of Matrix).

So at least for you, Renaud, the solution to the problem is easy:
Just don't do what you should not do: What you want is already
part of Matrix and after searching: It's been part of
Matrix since ca. July 2012 ...

-

But yes, there's a buglet in the 'methods' package currently,
which leads to a misleading error message
(It's arguable if it should give an error which it did not previously;
I think it would be quite a good idea to give at least a
warning as you are masking class definition of the Matrix
package which is in your search() path or at least among the
loaded namespaces at this time).

Best,
Martin


‐‐‐ Original Message ‐‐‐


 > On Wednesday, April 8, 2020 11:19 AM, William Dunlap  
wrote:



Use trace() to get a bit more detail - .__C_compMatrix is looked for in the 
wrong environment with inherits=FALSE.


 >>

 >>> setClassUnion("mMatrix", c("Matrix", "matrix"))

 >> Tracing get(name, envir = env) on entry

 >> x=".AllMTable", envir="", topenv="", inherits=TRUE

 >> Tracing get(name, envir = env) on entry

 >> x=".MTable", envir="", topenv="", inherits=TRUE

 >> Tracing get(name, envir = env) on entry

 >> x=".AllMTable", envir="", topenv="", inherits=TRUE

 >> Tracing get("#HAS_DUPLICATE_CLASS_NAMES", envir = .classTable) on entry

 >> x="#HAS_DUPLICATE_CLASS_NAMES", envir="", 
topenv="", inherits=TRUE

 >> Tracing get(name, envir = env) on entry

 >> x=".AllMTable", envir="", topenv="", inherits=TRUE

 >> Tracing get(name, envir = env) on entry

 >> x=".MTable", envir="", topenv="", inherits=TRUE

 >> Tracing get(name, envir = env) on entry

 >> x=".MTable", envir="", topenv="", inherits=TRUE

 >> Tracing get(".SigLength", envir = env) on entry

 >> x=".SigLength", envir="", topenv="", inherits=TRUE

 >> Tracing get(".SigLength", envir = env) on entry

 >> x=".SigLength", envir="", topenv="", inherits=TRUE

 >> Tracing get(name, envir = env) on entry

 >> x=".MTable", envir="", topenv="", inherits=TRUE

 >> Tracing get(".SigLength", envir = env) on entry

 >> x=".SigLength", envir="", topenv="", inherits=TRUE

 >> Tracing get(".SigLength", envir = env) on entry

 >> x=".SigLength", envir="", topenv="", inherits=TRUE

 >> Tracing get(cname, envir = cwhere, inherits = FALSE) on entry

 >> x=".__C__compMatrix", envir="", topenv="", inherits=FALSE

 >> Error in get(cname, envir = cwhere, inherits = FALSE) :

 >> object '.__C__compMatrix' not found

 >> ...

 >>

 >> Bill Dunlap

 >> TIBCO Software

 >> wdunlap tibco.com

 >>

 >> On Wed, Apr 8, 2020 at 7:52 AM William Dunlap  wrote:

 >>


Re: [R-pkg-devel] Error creating union class: object ‘.__C__compMatrix’ not found

2020-05-18 Thread renozao
Hi,

I tried to solve the issue in multiple ways, but I keep getting an installation 
error when running R CMD check, although the package installs fine with R CMD 
INSTALL:

Error: package ‘Matrix’ required by ‘NMF’ could not be found

I clearly have the package Matrix installed and up-to-date.
I tried with/without Matrix in Depends, with/without importing it all in the 
NAMESPACE.
Do I need to have a statement like this in the NAMESPACE:

importClassesFrom(Matrix,mMatrix)


The class appears not to be exported.
Puzzled.

Thank you.

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


Re: [R-pkg-devel] Error creating union class: object ‘.__C__compMatrix’ not found

2020-05-18 Thread renozao
So I can't use neither use the the class mMatrix form Matrix in my package, 
neither define an internal union class of ("Matrix", "matrix").
If I define a union class with a different name, then I have to import the 
class "Matrix" from Matrix or I get a check error.
But then I need to add Matrix as Depends (or I get an error, which makes sense).
The issue is that if I add Matrix as Depends I get the error that the package 
"Matrix" is not found, when checking if the package can be installed.
This error does not happen when installing with R CMD INSTALL.

I eventually managed to reproduce the error: as soon as I add ggplot2 in 
Imports I get the error.
A DESCRIPTION file with this breaks:

Depends:
  Matrix
Imports:
  ggplot2


I have Matrix 1.2.18 and ggplot2 3.3.0





Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐
On Monday, May 18, 2020 2:31 PM, Duncan Murdoch  
wrote:

> On 29/04/2020 1:16 p.m., renozao wrote:
>
> > Thank you Martin,
> > Looks like the mMatrix class defined in Matrix is not exported in 3.6.3, 
> > maybe it is now exported in the current R-devel.
>
> Matrix doesn't have the same versions as R: it's a recommended package,
> not a base package. It can be updated independently of R. The current
> version on CRAN is 1.2-18, but the R-forge version is 1.3-0. Neither
> one exports mMatrix.
>
> Duncan Murdoch
>
> > In this case I'd rather use a conditional import and definition.
> > I'll try that route.
> > Bests,
> > Renaud
> > Sent with ProtonMail Secure Email.
> > ‐‐‐ Original Message ‐‐‐
> > On Saturday, April 18, 2020 12:36 PM, Martin Maechler 
> > maech...@stat.math.ethz.ch wrote:
> >
> > > > > > > > renozao
> > > > > > > > on Wed, 8 Apr 2020 16:19:59 + writes:
> > >
> > > > Thank you William for the reproducible example.
> > >
> > >  > Currently I using the following (same as in William's example):
> > >
> > >  > setClassUnion("mMatrix", c("Matrix", "matrix"))
> > >
> > >
> > > > Martin, are the changes made in the union class handling affecting the 
> > > > way we should declare them?
> > >
> > > > Thank you.
> > >
> > > > Bests,
> > >
> > >  > Renaud
> > >
> > >
> > > Thank you, Renaud, and Bill Dunlap.
> > > There is obviously a bit of a problem there, but it may well be
> > > "only" a problem in error handling.
> > > As Bill's trace(get, ..) shows, R tries to get
> > > "#HAS_DUPLICATE_CLASS_NAMES" which is indeed an indication of the problem:
> > > You are trying to REdefine a class union that already exists
> > > identically in the Matrix package:
> > > In the R-forge development version of 'Matrix', it is
> > > line 717 of Matrix/R/AllClass.R (and that will be close also
> > > in the CRAN version of Matrix).
> > > So at least for you, Renaud, the solution to the problem is easy:
> > > Just don't do what you should not do: What you want is already
> > > part of Matrix and after searching: It's been part of
> > > Matrix since ca. July 2012 ...
> > >
> > > But yes, there's a buglet in the 'methods' package currently,
> > > which leads to a misleading error message
> > > (It's arguable if it should give an error which it did not previously;
> > > I think it would be quite a good idea to give at least a
> > > warning as you are masking class definition of the Matrix
> > > package which is in your search() path or at least among the
> > > loaded namespaces at this time).
> > > Best,
> > > Martin
> > >
> > > > ‐‐‐ Original Message ‐‐‐
> > >
> > >  > On Wednesday, April 8, 2020 11:19 AM, William Dunlap 
> > >  wrote:
> > >
> > >
> > > > > Use trace() to get a bit more detail - .__C_compMatrix is looked for 
> > > > > in the wrong environment with inherits=FALSE.
> > >
> > >  >>
> > >
> > >  >>> setClassUnion("mMatrix", c("Matrix", "matrix"))
> > >
> > >  >> Tracing get(name, envir = env) on entry
> > >
> > >  >> x=".AllMTable", envir="", 
> > > topenv="", inherits=TRUE
> > >
> > >  >> Tracing get(name, envir = env) on entry
> > >
> > >  >> x=".MTable", envir="", 
> > > topenv="", inherits=TRUE
> > >
> > >  >> Tracing get(name, envir = env) on entry
> > >
> > >  >> x=".AllMTable", envir="", 
> > > topenv="", inherits=TRUE
> > >
> > >  >> Tracing get("#HAS_DUPLICATE_CLASS_NAMES", envir = .classTable) on 
> > > entry
> > >
> > >  >> x="#HAS_DUPLICATE_CLASS_NAMES", envir="", 
> > > topenv="", inherits=TRUE
> > >
> > >  >> Tracing get(name, envir = env) on entry
> > >
> > >  >> x=".AllMTable", envir="", 
> > > topenv="", inherits=TRUE
> > >
> > >  >> Tracing get(name, envir = env) on entry
> > >
> > >  >> x=".MTable", envir="", 
> > > topenv="", inherits=TRUE
> > >
> > >  >> Tracing get(name, envir = env) on entry
> > >
> > >  >> x=".MTable", envir="", 
> > > topenv="", inherits=TRUE
> > >
> > >  >> Tracing get(".SigLength", envir = env) on entry
> > >
> > >  >> x=".SigLength", envir="", 
> > > topenv="", inherits=TRUE
> > >
> > >  >> Tracing get(".SigLengt