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

sorting article has a failing stopifnot expression #65

Open
jjallaire opened this issue Feb 3, 2015 · 4 comments
Open

sorting article has a failing stopifnot expression #65

jjallaire opened this issue Feb 3, 2015 · 4 comments
Labels

Comments

@jjallaire
Copy link
Member

@rbresearch I just made a change to the Gallery which causes articles to fail if they stop with an error. After doing this I noticed that the following expression from your sorting article was failing it's test

# check that the nth sorted elements of the vectors are equal
stopifnot(all.equal(stl_nth_element(x, 43)[43], sort(x, partial=43)[43]))

I temporarily removed the code so that the Gallery would build: f3de013

However it seems worth pursuing why the test is failing (it may have never worked in the first place but the error was just printed and we never noticed it).

@jjallaire jjallaire added the bug label Feb 3, 2015
@rbresearch
Copy link
Contributor

JJ,

Thanks for the note, I'll look into it and figure out why it is failing.

Thanks,
Ross

On Tue, Feb 3, 2015 at 4:49 PM, JJ Allaire [email protected] wrote:

@rbresearch https://github.com/rbresearch I just made a change to the
Gallery which causes articles to fail if they stop with an error. After
doing this I noticed that the following expression from your sorting
article
https://github.com/jjallaire/rcpp-gallery/blob/gh-pages/src/2013-01-31-sorting.cpp
was failing it's test

check that the nth sorted elements of the vectors are equal

stopifnot(all.equal(stl_nth_element(x, 43)[43], sort(x, partial=43)[43]))

I temporarily removed the code so that the Gallery would build: f3de013
f3de013

However it seems worth pursuing why the test is failing (it may have never
worked in the first place but the error was just printed and we never
noticed it).


Reply to this email directly or view it on GitHub
#65.

@eddelbuettel
Copy link
Member

Pinging @rbresearch

Ross, any news on this?

@rbresearch
Copy link
Contributor

Hi Dirk,

Sorry for the late response. I was stumped by this at first, but now I
think I have it figured out. The first time I ran the file with the
following line, it ran fine. I ran it a second time and then it failed. I
tried several different values of n and some worked while others did not. I
do not completely understand why it worked some of the time.

check that the nth sorted elements of the vectors are equal

stopifnot(all.equal(stl_nth_element(x, 43)[43], sort(x, partial=43)[43]))

There appears to be a bug in the stl_nth_element function and I made a
rookie mistake of not accounting for the 0-based indexing in C++. I tested
the fix for the vector x of different lengths and for all values of n and
the test passed for each case. I will submit a pull request shortly.

Ross

On Sun, Mar 22, 2015 at 1:27 PM, Dirk Eddelbuettel <[email protected]

wrote:

Pinging @rbresearch https://github.com/rbresearch

Ross, any news on this?


Reply to this email directly or view it on GitHub
#65 (comment)
.

@eddelbuettel
Copy link
Member

Thank you! I was out traveling but will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants