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

Add tests of forder NA/NaN behavior #3409

Merged
merged 1 commit into from
Feb 23, 2019
Merged

Add tests of forder NA/NaN behavior #3409

merged 1 commit into from
Feb 23, 2019

Conversation

MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented Feb 17, 2019

Also, all the TODOs here are now pulled into #2572, so removing them from the tests file (where they're less visible)

@codecov
Copy link

codecov bot commented Feb 17, 2019

Codecov Report

Merging #3409 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3409   +/-   ##
=======================================
  Coverage   95.12%   95.12%           
=======================================
  Files          65       65           
  Lines       12127    12127           
=======================================
  Hits        11536    11536           
  Misses        591      591

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 c4b195f...4fafb87. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Feb 17, 2019

Codecov Report

Merging #3409 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3409   +/-   ##
=======================================
  Coverage   95.12%   95.12%           
=======================================
  Files          65       65           
  Lines       12127    12127           
=======================================
  Hits        11536    11536           
  Misses        591      591

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 c4b195f...4fafb87. 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.

those new tests, they weren't just dput(forder()) right?

@MichaelChirico
Copy link
Member Author

they weren't just dput(forder()) right?

They were 😬

@jangorecki
Copy link
Member

So just please examine if returned values are expected ones. Such methodology of adding tests does tests only that returned values will not change over time but not if they are correct. It happens few times to me that I pushed incorrect tests like that.

@MichaelChirico
Copy link
Member Author

MichaelChirico commented Feb 17, 2019

Thanks @jangorecki. I actually think current behavior is inconsistent:

x = data.table(r = c(6, 4, 2, NA, 1, NaN, 5, NaN, 9, 10, NA))

x[order(r, na.last = TRUE)]
#         r
#     <num>
#  1:     1
#  2:     2
#  3:     4
#  4:     5
#  5:     6
#  6:     9
#  7:    10
#  8:   NaN
#  9:   NaN
# 10:    NA
# 11:    NA
x[order(r, na.last = FALSE)]
#         r
#     <num>
#  1:    NA
#  2:    NA
#  3:   NaN
#  4:   NaN
#  5:     1
#  6:     2
#  7:     4
#  8:     5
#  9:     6
# 10:     9
# 11:    10
x[order(-r, na.last = TRUE)]
#         r
#     <num>
#  1:    10
#  2:     9
#  3:     6
#  4:     5
#  5:     4
#  6:     2
#  7:     1
#  8:   NaN
#  9:   NaN
# 10:    NA
# 11:    NA
x[order(-r, na.last = FALSE)]
#         r
#     <num>
#  1:    NA
#  2:    NA
#  3:   NaN
#  4:   NaN
#  5:    10
#  6:     9
#  7:     6
#  8:     5
#  9:     4
# 10:     2
# 11:     1

If NA > NaN, 3rd (x[order(-r, na.last = TRUE)]) looks wrong. Similarly for the 2nd one looking off.

@jangorecki jangorecki changed the title Add tests of forder NA/NaN behavior (#2572); also purge tests of TODO… [WIP] Add tests of forder NA/NaN behavior (#2572); also purge tests of TODO… Feb 17, 2019
@jangorecki
Copy link
Member

I renamed to WIP so it won't be yet merged, lets first agree on expected output.

@mattdowle mattdowle added this to the 1.12.2 milestone Feb 20, 2019
@mattdowle mattdowle changed the title [WIP] Add tests of forder NA/NaN behavior (#2572); also purge tests of TODO… [WIP] Add tests of forder NA/NaN behavior Feb 23, 2019
@mattdowle
Copy link
Member

mattdowle commented Feb 23, 2019

Great discussion. I think of the ordering of NA and NaN as different to the ordering of the finite numbers: if na.last is provided then NA and NaN are put at the beginning or the end in a fixed order such that NA is always at the end with NaN before the NA. I doubt it matters really, just that the choice is consistent.
I installed both v1.9.8 and v1.11.8 and checked the results checked in this PR match the results then. All good. So for the reason of consistency over time, these tests look good to me.

@mattdowle mattdowle changed the title [WIP] Add tests of forder NA/NaN behavior Add tests of forder NA/NaN behavior Feb 23, 2019
@mattdowle mattdowle merged commit 596971e into master Feb 23, 2019
@mattdowle mattdowle deleted the todo_cleanup branch February 23, 2019 03:04
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.

3 participants