-
Notifications
You must be signed in to change notification settings - Fork 55
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
Convert SciPy sparse matrix to R #158
Conversation
Yes. We now use the reticulate package, but in the (older) Travis setup I still use we have to explicitly tell Travis about it in the |
I get the tests to run if I
But one test still fails: > coo <- sp$coo_matrix(mat)
> dgT <- methods::as(M, "dgTMatrix")
> checkEquals(dgT, py2r(coo), msg="coo2dgt")
Error in checkEquals(dgT, py2r(coo), msg = "coo2dgt") :
Attributes: < Component “i”: Mean relative difference: 1.2 >
Attributes: < Component “j”: Mean relative difference: 1.2 >
Attributes: < Component “x”: Mean relative difference: 0.5714286 >
coo2dgt
> even though > py2r(coo)
3 x 3 sparse Matrix of class "dgTMatrix"
[1,] 1 . 4
[2,] . . 5
[3,] 2 3 6
> dgT
3 x 3 sparse Matrix of class "dgTMatrix"
[1,] 1 . 4
[2,] . . 5
[3,] 2 3 6
> M
[,1] [,2] [,3]
[1,] 1 0 4
[2,] 0 0 5
[3,] 2 3 6
> If I comment the corresponding test out, and make some corrections to |
Well, I'm checking what happens in coo2dgt.
The problem exists because |
I have a commit pending which "works here" in the sense of
But I fear we may get an old SciPy on the older Travis setup -- so even if it "works for me here" we may not get a working setup at Travis. |
Ok, see this branch started from your PR. It just passed a test run on Travis. There are still a number of open issues. Let's not rush this. |
After checking the unit tests for sparse matrix conversion in RcppArmadillo I wrote before,
Personally, I think the current conversion result for SciPy coo sparse matrix is fine and whether to pass the unit test just depends on the generation method of dgTMatrix and its |
The three cases are not randomly selected though, are they? Could we do a weaker comparison like this one:
|
Most dgTMatrix is column-oriented, including created by Not quite understood the reason for using weaker comparison. Do you mean comparing the non-zero values for different kinds of sparse matrix in this SciPy sparse matrix conversion? like the conversion results of |
So can you create one that would match what we get via SciPy ? |
Done. And local tests pass. |
Are you ok with my other changes? Ie We can leave things the way they are now, or set this up as a |
Yes, that's fine. |
R/py2r.R
Outdated
## You should have received a copy of the GNU General Public License | ||
## along with RcppArmadillo. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
requireNamespace("reticulate", quietlty=TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also did some gentle renaming as py2r
as bit too generic.
@binxiangni Can you rebase / pull one more time to get my last commit over here too? Otherwise I can merge as is and then PR from my branch to just get its final commit over. |
Done. Sorry for the late action. Still in China, so there is a time difference. |
Oh, I was unaware you were away.... |
I did some minor modification to support the conversion of SciPy sparse matrix to R. It seems that I mistook the setup in my unit test so that compiler errors occurred. Any hints to correct it?