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

New warning for %between% #3015

Merged
merged 2 commits into from
Aug 29, 2018
Merged

New warning for %between% #3015

merged 2 commits into from
Aug 29, 2018

Conversation

MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented Aug 29, 2018

Closes #3014

R/between.R Outdated
"%between%" <- function(x, y) {
if (length(y) > 2L) {
ysub = substitute(y)
warning("RHS has length() greater than 2. ",
Copy link
Member

Choose a reason for hiding this comment

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

à la if (1:5 > 1) "a" we should indicate that part of the input is being ignored: "RHS has length > 2 and only the first and second elements will be used".

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought to include that, but didn't want an overlong message; you don't think that's strongly implied by the warning here?

Maybe:?

RHS has length() greater than 2 and the rest will be ignored. [...]

Copy link
Member

Choose a reason for hiding this comment

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

I think a problem can arise when the user says y = c(B, B + 1), 'knowing' that length(y) > 2 -- duh! It's vectorized; the warning is nothing to worry about.

On second thoughts, maybe this should be an error. Documentation is pretty clear that y must be length-2, it was just never enforced. I'm trying to think of a case where only a warning is appropriate.

The suggestion (Perhaps...) should obviously stay: that's imo the most valuable part of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also was struggling to think of a use case that's not subsumed by just running [1:2] on whatever your input is (and even the [1:2] cases i couldn't think of a real use case)

Copy link
Member Author

Choose a reason for hiding this comment

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

A point well taken re "knowing" length(y) > 2. My writing was intended to convey/hint/poke "Hmm maybe I should check length(RHS) since I thought it was 2", but being more explicit is less prone to errors of assuming

Copy link
Member Author

Choose a reason for hiding this comment

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

@HughParsonage updated

@codecov
Copy link

codecov bot commented Aug 29, 2018

Codecov Report

Merging #3015 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3015      +/-   ##
==========================================
+ Coverage   90.81%   90.82%   +<.01%     
==========================================
  Files          61       61              
  Lines       11728    11736       +8     
==========================================
+ Hits        10651    10659       +8     
  Misses       1077     1077
Impacted Files Coverage Δ
R/between.R 96.96% <100%> (+0.96%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d4ce7a...309462a. Read the comment docs.

Copy link
Member

@jangorecki jangorecki left a comment

Choose a reason for hiding this comment

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

LGTM

Also change NEWS

whitespace
@mattdowle mattdowle changed the title Closes #3014, new warning for %between% New warning for %between% Aug 29, 2018
@mattdowle mattdowle added this to the 1.11.6 milestone Aug 29, 2018
@mattdowle mattdowle merged commit bff7521 into master Aug 29, 2018
@mattdowle mattdowle deleted the between_warning branch August 29, 2018 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants