-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Restore behaviour from 0.10-2 to .xts() #250
Restore behaviour from 0.10-2 to .xts() #250
Conversation
Hmm the checks pass locally on R 3.5.1. I'll investigate. |
I'm stumped, I can't replicate the test failures on any of the 3 machines I have easy access to. Any hints would be appreciated. |
Since the failing test is for the |
049ac98
to
9f74e20
Compare
Yes, explicitly setting TZ in |
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.
Generally, tests should cover the API, not the implementation. That said, it may make sense to keep the checks for the tclass
and tzone
attributes on the index, since they will be necessary once the index class and index timezone are attributes on the index, not the xts object.
I am interested in whether using the API's extractor functions would change the results of the test cases that pass in 0.10-2 but look wrong. It would be great if you could make those changes to the checkXts*()
functions and re-test on 0.10-2.
@@ -50,3 +50,52 @@ test..xts_dimnames_in_dots <- function() { | |||
y <- xts(1:5, index(x), dimnames = list(NULL, "x")) | |||
checkEquals(x, y) | |||
} | |||
|
|||
checkXtsClass <- function(xts, class) { |
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.
This test looks for attributes on specific objects, but it probably should use the extractor functions indexClass()
and tclass()
.
inst/unitTests/runit.xts.R
Outdated
checkXtsClass(.xts(1, structure(1, tzone="",tclass="yearmon"), tclass="timeDate", .indexCLASS="Date"), "Date") | ||
} | ||
|
||
checkXtsTz <- function(xts, tzone, .indexTZ) { |
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.
This test looks for attributes on specific objects, but it probably should use the extractor functions indexTZ()
and tzone()
.
I've added a commit to alter the two Testing in It seems that for timezones in As it stands this pull request reinstates the behaviour from Do let me know if you'd like any other changes. |
8ff55d1
to
993434a
Compare
In fact, on closer inspection, my changes to the handling of I can squash this down if you're happy. |
Thanks for noticing this and mentioning it. The plan is to deprecate This looks good to me now. I would appreciate a cleaned-up history (squash or rebase, depending on what you think tells the story better), especially:
|
As documented in joshuaulrich#249, v0.11 introduced changes to .xts() which altered behaviour compared to v0.10-2. As a first step to fixing this regression, this commit adds unit tests for all possible permutations for setting the index class and timezone in .xts(). The tests check accessing the class in 3 different ways: 1. Using tclass() 2. Using indexClass() 3. Checking the 'tclass' attribute on the index object Similarly the tests check accessing timezone by: 1. Using tzone() 2. Using indexTZ() 3. Checking the '.indexTZ' attribute on the index object These tests are designed to document the behaviour as of v0.10-2. As such they pass on v0.10-2 but fail for v0.11.
Reinstate the behaviour as of v0.10-2. .indexCLASS should take precedence over tclass. Fixes joshuaulrich#249.
2917a21
to
1d707c5
Compare
Great work @TomAndrews! Thank you very much for your contributions! |
Add unit tests to document the behaviour in 0.10-2 and fix the failures introduced in 0.11. Fixes #249.