Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sugar median with unit tests#425

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

Merged
eddelbuettel merged 4 commits intoRcppCore:masterfromnathan-russell:master
Jan 21, 2016
Merged

Sugar median with unit tests#425

eddelbuettel merged 4 commits intoRcppCore:masterfromnathan-russell:master
Jan 21, 2016

Conversation

@nathan-russell
Copy link
Contributor

As discussed in#424, this adds a sugar functionRcpp::median with corresponding unit tests.

Copy link
Member

Choose a reason for hiding this comment

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

I have a much newer version of this line but then I never said anything official about it...

@eddelbuettel
Copy link
Member

This looks good. I had in the back of my mind a though that R'smedian() had a bazillion further options, but maybe I was thinking aboutquantile() and its (crazy but impressive)type= argument.

So this is probably good too but one or two seconds would be nice.

@nathan-russell
Copy link
ContributorAuthor

Okay, that sounds good. In the meantime I will make the appropriate changes regarding your comments above. Is this the newer version of the formatting line you referred to:

-*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-

@eddelbuettel
Copy link
Member

Yep. Hard tabs are evil, which we learned eventually. But I leave commits touching every single file to@kevinushey :) -- in short, bulk changes aren't worth it either.

There isn't too much about code style you don't already know or do. Four spaces is better than too, indentation pretty much like R Core and other sensible people do etc pp. No biggies.

@nathan-russell
Copy link
ContributorAuthor

Agreed on the spaces vs. tabs - it was just sloppy copy & paste on my part from another sugar file, and being avim guy (sorry!) the outdated formatting settings didn't catch my eye.

@kevinushey
Copy link
Contributor

FWIW we now use.dir-locals.el to enforce indentation rules when editing with Emacs; does Vim have an analogue for directory-local variables / indentation rules?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm -- we clone the vector here because thestd:: algorithm we use will modify the passed vector?

@thirdwing
Copy link
Member

Maybe we can also have a.vim.custom to set indent.

But if we really want to have a consistent coding style, we might think about cpplint from Google.

@eddelbuettel
Copy link
Member

Re.dir-locals.el, the fanciest / most general scheme I know is viaeditorconfig where, as I understand it, you define a 'policy' or outcome and the editor-specific plugins implement it in the editor of choice.

Alternatively, and there clang-format but all of that is a bit of the heavy-handed side.

@eddelbuettel
Copy link
Member

My bad for the close and re-open. Hit the wrong button.

@kevinushey
Copy link
Contributor

Other than some minor comments this looks good to me.

@nathan-russell
Copy link
ContributorAuthor

@kevinushey Thanks for the feedback - I do believe it is necessary to callRcpp::clone in the constructor as above. I just did a rebuild without the use ofclone and it appears to modify the original vector:

#include<Rcpp.h>// [[Rcpp::export]]doublemedian_dbl(Rcpp::NumericVector x,bool na_rm =false) {returnRcpp::median(x, na_rm);}// [[Rcpp::export]]doublemedian_int(Rcpp::IntegerVector x,bool na_rm =false) {returnRcpp::median(x, na_rm);}// [[Rcpp::export]]Rcomplexmedian_cx(Rcpp::ComplexVector x,bool na_rm =false) {returnRcpp::median(x, na_rm);}// [[Rcpp::export]]Rcpp::Stringmedian_ch(Rcpp::CharacterVector x,bool na_rm =false) {returnRcpp::median(x, na_rm);}/*** Rset.seed(123)(xx <- rnorm(5))#[1] -0.56047565 -0.23017749  1.55870831  0.07050839  0.12928774median_dbl(xx)#[1] 0.07050839xx#[1] -0.56047565 -0.23017749  0.07050839  0.12928774  1.55870831set.seed(123)(xx <- as.integer(rpois(5, 20)))#[1] 17 25 12 20 27median_int(xx)#[1] 20xx#[1] 17 12 20 25 27set.seed(123)(xx <- rnorm(5) + 2i)#[1] -0.560476+2i -0.230177+2i  1.558708+2i  0.070508+2i  0.129288+2imedian_cx(xx)#[1] 0.070508+2ixx#[1] -0.560476+2i -0.230177+2i  0.070508+2i  0.129288+2i  1.558708+2iset.seed(123)(xx <- sample(letters, 5))#[1] "h" "t" "j" "u" "w"median_ch(xx)#[1] "t"xx##[1] "h" "j" "t" "u" "w"*/

As for the other points, I'll setRTYPE2 toRESULT_RTYPE and swap out theswitch statement with anif statement and commit the changes.

I have not used / am not aware of anything analogous to.dir-locals.el or the Emacs configuration lines embedded in the Rcpp headers; I just have the standard~/.vimrc and~/.vim/ftplugin/*.vim files on my machines.

@eddelbuettel
Copy link
Member

Time to pull this one in!

eddelbuettel added a commit that referenced this pull requestJan 21, 2016
@eddelbuetteleddelbuettel merged commitfcbfcc6 intoRcppCore:masterJan 21, 2016
@nathan-russell
Copy link
ContributorAuthor

👍

@eddelbuettel
Copy link
Member

No, thumbs up toyou -- that was really well done (but I was a little tied up yesterday and the day before).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@nathan-russell@eddelbuettel@kevinushey@thirdwing

[8]ページ先頭

©2009-2025 Movatter.jp