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

append without losing timezones in strip_pts #413

Merged
merged 7 commits into from
Nov 15, 2016

Conversation

lindsayplatt
Copy link

@lindsayplatt lindsayplatt commented Nov 7, 2016

Working on #285

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 79.631% when pulling de0767d on lindsaycarr:master into 8a1eb23 on USGS-R:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 79.631% when pulling de0767d on lindsaycarr:master into 8a1eb23 on USGS-R:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 79.13% when pulling 6ba68c5 on lindsaycarr:master into 8a1eb23 on USGS-R:master.

} else {
out <- append(out, NA)
out <- append_keepTZ(out, NA, tz=attr(out, "tzone"))
Copy link
Member

Choose a reason for hiding this comment

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

is it not necessary to set the class here too? Just wondering what cases we lose it for, and if this is a safe one

Copy link
Member

Choose a reason for hiding this comment

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

In my experience, POSIX's and Dates tend to keep their class, but they get attributes stripped off for various reasons. So, my guess is that this is fine.

Copy link
Author

Choose a reason for hiding this comment

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

That was only when all of "v.vals" was NA - we had to be explicit about what class it should have. Otherwise, it will have the same class as v.vals.

@lindsayplatt
Copy link
Author

@jread-usgs @ldecicco-USGS merge-ready?

} else {
if (any(sapply(list, is.list))){
u.list <- unname_c(list[sapply(list, is.list)])
if(v %in% names(u.list)) {
v.vals <- u.list[[v]]
out <- append(out, v.vals)
out.class <- ifelse(!all(is.na(v.vals)), class(v.vals), out.class)
out <- append_keepTZ(out, v.vals, tz=attr(v.vals, 'tzone'))
Copy link
Member

Choose a reason for hiding this comment

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

Would there ever be a case where we were going to use some other tz? If not, should it just be moved into the function?:

append_keepTZ <- function(base.vals, append.vals){
 tz <- attr(append.vals, "tzone")   
 vals <- append(base.vals, append.vals)
   attr(vals,"tzone") <- tz
   return(vals)
 }

Copy link
Author

Choose a reason for hiding this comment

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

Some keep the tz to be from base.vals, and some from append.vals, so I kept it outside. Most need to look at the tzone of the values you are appending because you could be appending to an empty object. However, sometimes you are appending an NA (see L66), and then you need to keep the tzone from the existing object.

@ldecicco-USGS ldecicco-USGS merged commit 745a3b0 into USGS-R:master Nov 15, 2016
@ldecicco-USGS
Copy link
Member

So, I merged this, then remembered...it's always good to see that the gsplotIntro.html file has at least a minor update (because we show the date). Then we know that all the vignette and (ideally) readme plots look the same.

@lindsayplatt
Copy link
Author

Except that we don't commit the html file, so how could we tell if there was a difference?

@ldecicco-USGS
Copy link
Member

Why not? I do...

@ldecicco-USGS
Copy link
Member

Oh, I see @jread-usgs added it to the git ignore...I have no idea why. I consider it a part of the tests. I'm taking it off the git ignore

@ldecicco-USGS
Copy link
Member

ldecicco-USGS commented Nov 15, 2016

No, actually he's right. It's ignored from the vignette folder, but not the "proper" location in inst/doc. So, before each PR...you should be doing:

devtools::build_vignettes()

and knitting the Readme.Rmd.

@lindsayplatt
Copy link
Author

just ran it - it did not actually change anything. I think it's because none of our examples have timezones, so they were showing up just fine.

@ldecicco-USGS
Copy link
Member

I didn't expect it to change anything...just mentioning that it's probably a good idea to always include it in your (and all of our) pull requests. At least the date up top changed though, right?

https://rawgit.com/ldecicco-USGS/gsplot/master/inst/doc/gsplotIntro.html

right under the author list, there's the date.

@lindsayplatt
Copy link
Author

oh yes - that changed. Worth making a new PR for though?

@jordansread
Copy link
Member

Agree @ldecicco-USGS, since we can't do visual tests, we should bug each other in PR reviews to include the knits

@ldecicco-USGS
Copy link
Member

Not worth another PR (I've actually got it in mine now....)...just mentioning for the future.

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