-
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
Rewrite conversion for dgT, dtT & dsTMatrix & add file-based tests #142
Conversation
The change to the header file looks good and careful -- though I only glanced at it. It is quite possible that you fixed an error which had been hiding there for some time. I am wondering if we can do better on the (short) included cpp file? Ie for the rest of the package we have the cpp files in this directory which already has a file for sparse matrix tests. Could you use that mechanism, and call via unit test functions as in this file ? |
Maybe I don't totally understand what you mean, but for now,I just call the cpp file to do the unit tests. The unit test is so long just because I have to write a new triangular and a new symmetric matrix to test them. |
You added two files to subdirectory And what the package does internally is to use the RUnit package to have the file tests/doRUnit.R automatically call everything in the unit tests directory. And we already have 1) a file for sparse tests there which you could add two, or complement witha new one, and 2) a C++ file there to support it -- so you short C++ function could go there. Have a look at those files, and what happens when you do |
Also, what we could do is to
I could do that if you want me to. And I'll make sure you end up in the corresponding copyright headers. |
I've integrated the previous files into the unitTests folder. Please help me check if the format and copyright headers are appropriate. And I passed the tests locally, but it's weird it didn't work on the website. I checked the log and the error happened runit.sparse.R. But I didn't touch it. |
It seems the unit test also passed on my machine. Let's restart the Travis and see what happens. |
# Matrix | ||
# https://cran.r-project.org/web/packages/Matrix/Matrix.pdf | ||
|
||
## p10 (dgCMatrix) |
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.
I think you mean page 10, right? Just want to make sure.
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.
Yes, it represents the 10th page of documentation of package Matrix.
Thanks for making the chamges! I can take a look tomorrow. Bed-time here in Brussels... |
dgc <- as(M, "dgCMatrix") | ||
checkEquals(dgc, asSpMat(D5), msg="ddi2dgC") | ||
|
||
# mtxt <- c("0.1 0 0 0 0", |
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.
Can I know why this test has been commented out?
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 test didn't pass. I guess it's because the rounding precision. I leave it for further check.
@binxiangni I am afraid you are using a wrong format for RUnit. For example, in https://github.com/binxiangni/RcppArmadillo/blob/master/inst/unitTests/runit.sparseConversion.R#L39-L43 set.seed(7)
m <- matrix(0, 5, 5)
m[sample(length(m), size = 14)] <- rep(1:9, length=14)
mm <- as(m, "CsparseMatrix")
checkEquals(mm, asSpMat(mm), msg="dgC2dgC") This should be test.as.dgC2dgC <- function() {
set.seed(7)
m <- matrix(0, 5, 5)
m[sample(length(m), size = 14)] <- rep(1:9, length=14)
mm <- as(m, "CsparseMatrix")
checkEquals(mm, asSpMat(mm), msg="dgC2dgC")
} This should make Travis CI happy. See https://travis-ci.org/thirdwing/RcppArmadillo |
…conversion of sparse matrices
Now the new unit test file should be fine. This is a good lesson for me to learn how to do unit tests in RUnit. Thanks for instruction. :) |
Yes, looks much better :) With this in line 552:
Do you want to complete this, or shall we merge now? |
That's for the next stage, since some of conversion is not achieved now. I just note that in order to remind myself. You can merge that, if no error is found. |
First, the file-based tests are based on the documentation from package Matrix, sparseM, spam, slam, SciPy.
Second, when I did the file-based tests, I found two extreme cases that the original conversion for TsparseMatrix cannot satisfy, so I rewrite the conversion.
The two new cases include:
Last, I've passed the tests, but there is a warning that
Warning in read_symbols_from_dll(so, rarch) :
this requires 'objdump.exe' to be on the PATH
Should I do something?