Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

39 errors in projectr method for sparse matrix data #42

Merged
merged 13 commits into from
Nov 14, 2024

Conversation

dimalvovs
Copy link
Collaborator

  • implement projectR on sparseMatrix by calling the dense one in chunks;
  • fix missing LinearEmbeddingMatrix class definition
  • refactor

@dimalvovs dimalvovs linked an issue Sep 26, 2024 that may be closed by this pull request
@dimalvovs dimalvovs marked this pull request as ready for review September 26, 2024 22:25
NP=NA, # vector of integers indicating which columns of loadings object to use. The default of NP=NA will use entire matrix.
full=FALSE, # logical indicating whether to return the full model solution. By default only the new pattern object is returned.
family="gaussianff" # VGAM family function (default: "gaussianff")
NP=NULL, # vector of integers indicating which columns of loadings object to use. The default of NP=NA will use entire matrix.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment to match new default

Copy link

@drbergman drbergman Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, it's noteworthy to me that the default for NP is NA above and NULL here. Not sure if it's desired. just noting it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, because is.na(NP) was never going to work if NP is specified:

> NP <- c(1,3,5)
> if(!is.na(NP)) {print("it's a bug")}
Error in if (!is.na(NP)) { : the condition has length > 1

is.null works fine:

> is.null(NP)
[1] FALSE

see line 85 too - I changed the check from is.NA to is.null too


pdense <- projectR(dense, loadings, full=TRUE)
psparse <- projectR(sparse, loadings, full=TRUE)
expect_identical(projectR(dense, loadings),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to test that pdense and psparse are identical? Not sure why here (and above) you compute projectR twice for both dense and sparse, but at least here you want full=TRUE inside the expect_identical call, yeah?

Copy link
Collaborator Author

@dimalvovs dimalvovs Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, thanks for spotting and that's why we need reviews! fixed in c3fdb7a

Copy link

@drbergman drbergman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, this PR simplifies the code and makes it more readable. I can't quite tell what's being removed in R/projectR.R L104-126, but I'm guessing the call on new L106 handles that now. I left a couple comments throughout the changes.

Also, the PR message suggests that the LinearEmbeddingMatrix class def is being fixed. I can't find a place where it is being changed, let alone fixed.

@dimalvovs
Copy link
Collaborator Author

@drbergman thanks very much for the review, LinearEmbeddingMatrix definition is fixed in 5b1a15a

@dimalvovs dimalvovs merged commit 754af18 into master Nov 14, 2024
3 checks passed
@dimalvovs dimalvovs deleted the 39-errors-in-projectr-method-for-sparse-matrix-data branch November 14, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors in projectR method for sparse matrix data
3 participants