Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork219
Add at accessors with bounds checking#342
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
eddelbuettel commentedAug 16, 2015
Could you add a quick A new unit tests or two would be awesome too... |
2e4f026 to0eb5603Comparef565701 tobbe2bbeCompare574d5e9 tod22e29aComparefplazaonate commentedAug 17, 2015
I am quite lost here. |
eddelbuettel commentedAug 17, 2015
That looks like a Travis issiue:
is not something I have ever seen. |
eddelbuettel commentedAug 17, 2015
d22e29a to608b561Compareeddelbuettel commentedAug 17, 2015
Maybe we should reopen this? We still need to understand why Travis fails here. Is this a feature of anything here? |
eddelbuettel commentedAug 17, 2015
You are clearly having trouble with Travis CI. So let's look at this from a different angle. What happens when you |
fplazaonate commentedAug 17, 2015
Builds fails while generating the documentation I have not root privileges to install this missing package. |
eddelbuettel commentedAug 17, 2015
See |
fplazaonate commentedAug 17, 2015
I can't install the package 'highlight' because it's not available for R version 3.0.2 |
eddelbuettel commentedAug 17, 2015
Why are you on R 3.0.2? You can try an older version ofhighlight from its archive section. You can also locally edit away the Suggests: for Rcpp as highlight is needed only for the vignettes you are skipping anyway. |
fplazaonate commentedAug 17, 2015
I work on R 3.0.2 because this is the version installed on our server. Everything seems ok. |
eddelbuettel commentedAug 17, 2015
Ok, that looks better. One step in the right direction. Now we need to figure out why Travis CI no longer likes your commits. I don't have a good idea for that other than bisecting / backtracking to what worked before. |
thirdwing commentedAug 17, 2015
Please try to add |
eddelbuettel commentedAug 17, 2015
Nice. I was also thinking that it may be the old-vs-new Travis setup but couldn't quite think through why it was new for me and old for@FPlaza. And we do have
|
fplazaonate commentedAug 17, 2015
Disabling the cache doesn't work. |
fplazaonate commentedAug 19, 2015
Test fails because Rcpp uses wrong integer types so "v.at(-1)" is considered valid. |
fplazaonate commentedAug 19, 2015
Finally! |
eddelbuettel commentedAug 19, 2015
Hm. There is something about this that I do not like.If we think that bounds checking has meritand the type of the index is |
fplazaonate commentedAug 19, 2015
No, because 'at' accessors rely on the following methods which are ill-typed. /** * offset based on the dimensions of this vector*/size_toffset(constsize_t& i,constsize_t& j)const {if( !::Rf_isMatrix(Storage::get__()) )thrownot_a_matrix() ;/* we need to extract the dimensions*/int *dim =dims() ;size_t nrow =static_cast<size_t>(dim[0]) ;size_t ncol =static_cast<size_t>(dim[1]) ;if( i >= nrow || j >= ncol )throwindex_out_of_bounds() ;return i + nrow*j ; }/** * one dimensional offset doing bounds checking to ensure * it is valid*/size_toffset(constsize_t& i)const {if(static_cast<R_xlen_t>(i) >= ::Rf_xlength(Storage::get__()) )throwindex_out_of_bounds() ;return i ; } |
eddelbuettel commentedAug 19, 2015
So how about adding this just after the assignment to if (dim[0] <0 || dim[1] <0)throwindex_out_of_bounds(); with (optionally) a message about non-permissible negative indices? Edit Yes, or your patch. |
fplazaonate commentedAug 19, 2015
This looks quite hackish. |
eddelbuettel commentedAug 19, 2015
Slow down, we HAVE an open issue to discuss this. This one. What would a new one add? |
fplazaonate commentedAug 19, 2015
Because it is strongly related to a problem which is more general that we discussed before: |
eddelbuettel commentedAug 19, 2015
Of course. And negative values is as much a violation as are beyond-size values. Your patch was missing that, now it has it. Better. |
fplazaonate commentedAug 19, 2015
I was for a patch that solves the problem globally but I can propose one which solves it just for the "offset" methods. |
fplazaonate commentedAug 21, 2015
Tell me if it is ok now. |
eddelbuettel commentedAug 21, 2015
Sorry, we're all a little swamped. It looks pretty good to me. @kevinushey@jjallaire Any seconds? |
fplazaonate commentedAug 21, 2015
No worries. I was just wondering if you received a notification of my commit. |
kevinushey commentedAug 21, 2015
Looks okay to be, but does changing the signature of the |
jjallaire commentedAug 21, 2015
We can change interfaces and signatures without breakage so long as they On Aug 21, 2015, at 5:21 PM, Kevin Usheynotifications@github.com wrote: Looks okay to be, but does changing the signature of the offset() function — |
kevinushey commentedAug 21, 2015
That is indeed the case here, so I think we're safe. |
eddelbuettel commentedAug 22, 2015
The ABI change tester was mostly as exasperated attempt to see if we could dosomething. As I recall, I use a prebuilt binary package (on Travis) and try to load it. I don't think this would detect a changed-but-not-used-here alteration to function signatures. It may be better than not testing at all but I think it is still far from perfect. That said, I think this change does look as if it should be 'clean'. |
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.
Am I missing something or should the msg be "index out of bounds" because the fact that we have an exception means yourthrow went into effect?
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.
Actually, the error message is written if there is no error generated (c.f. RUnit documentation)
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 guess you are correct -- if it passes we just getTRUE. But if you look at our code the msg field, when we set it all :), mostly just states where this came from. So "matrix bounds check" would be fine, and s/matrix/vector/ for the other one.
Not that important. I'll try merge this maybe late this evening if I get to it. It now needs a manual intervention because ChangeLog changed in the meantime ...
eddelbuettel commentedAug 25, 2015
Ok, at long last this has been merged. Sorry again for the earlier trouble with the (entirely unrelated) issue caused by R 3.2.2 and unit testing, and thanks for the contribution, and your patience in seeing it through. |
I just made a copy of the operators() by making sure that bound are checked.