Skip to content

Make Quantity and Time/TimeDelta consistent attribute naming - #767

Merged
taldcroft merged 3 commits into
astropy:masterfrom
mhvk:time-val-to-value
Sep 9, 2013
Merged

taldcroft merged 3 commits into
astropy:masterfrom
mhvk:time-val-to-value

Conversation

@eteq

@eteq eteq commented Sep 7, 2013

Copy link
Copy Markdown
Member

As @taldcroft noted in #751, the Time object and Quantity objects have some similar-sounding attributes that are not quite the same. val and vals for Time/value for Quantity, and is_scalar for Time/isscalar for Quantity. We should probably adjust these to be the same. Then people don't have to try to remember which is which.

Personally, I'm for value/values over val/vals - it's only a couple more characters and quite a bit more readable.

isscalar vs is_scalar: I think I wrote isscalar, and I think I did it that way because it's how the numpy function is named. Also, it's a property rather than a method and attributes/properties in my head aren't underscore-delimited. But I don't think that's in PEP8, so I have no strong opinion.

I'm tagging this for 0.3, but if this quickly settles on an answer and is easy to implement, we might slip it into 0.2 to keep from breaking compatibility (@iguananaut ?)

@taldcroft

Copy link
Copy Markdown
Member

I'm OK with changing Time to be consistent with Quantity.

With Time you can (and should) do almost everything you need without val, vals or isscalar. So I'd vote to put this off to 0.3 and then just go through one release where the former names are available but give a deprecation warning.

@eteq

eteq commented Feb 12, 2013

Copy link
Copy Markdown
Member Author

Alright, that plan sounds good @taldcroft - we'll leave this as 0.3 then.

@mhvk

mhvk commented Aug 17, 2013

Copy link
Copy Markdown
Contributor

Encountered this while looking through old issues -- think this should be tagged 0.3.

My suggestion would be to replace self.val with self.value, drop self.vals, and replace self._time.vals with self._time.value,

@embray

embray commented Aug 19, 2013

Copy link
Copy Markdown
Member

+1 to unnecessarily abbreviated attribute names

@taldcroft

Copy link
Copy Markdown
Member

@mhvk - your suggestion is fine with me. I don't remember the original motivation for providing the always-vectorized version self.vals, but I can't think of anything really strong now so I think it's OK to remove.

We need to have a deprecation release (0.3) for self.val and self.vals. Since self.time._vals is internal that can just happen.

@mhvk

mhvk commented Sep 7, 2013

Copy link
Copy Markdown
Contributor

@eteq - I make a quick branch [1] that does the name changes in Time (and even corrects a bug in the process, that Time(single-datetime).value did not work). Could you attach it to this issue? (I cannot do that myself)

[1] https://github.com/mhvk/astropy/tree/time-val-to-value

(also tests that Time.now().value works, or any Time(single-datetime).value)
@eteq

eteq commented Sep 7, 2013

Copy link
Copy Markdown
Member Author

@mhvk - your branch is now attached.

In the future, it's also fine (perhaps even preferred?) to just create a new PR. As long as one of the commit messages says closes #767, merging it will automatically close this issue.

@eteq

eteq commented Sep 7, 2013

Copy link
Copy Markdown
Member Author

As for the content of the PR, @mhvk, it looks fine to me except for the tweaks I've issued to your branch in mhvk#3 which change __repr__ to match these name changes.

Change __repr__ to use value instead of vals
@mhvk

mhvk commented Sep 7, 2013

Copy link
Copy Markdown
Contributor

@eteq - thanks! I've merged your PR (yikes! that I missed so many...). also good to learn about the closes #... method.

@eteq

eteq commented Sep 8, 2013

Copy link
Copy Markdown
Member Author

np - @taldcroft, does this look good to you? looks good to merge to me now.

taldcroft added a commit that referenced this pull request Sep 9, 2013
Make Quantity and Time/TimeDelta consistent attribute naming
@taldcroft
taldcroft merged commit bd92fac into astropy:master Sep 9, 2013
@taldcroft

Copy link
Copy Markdown
Member

Merged, thanks @mhvk and @eteq !

@mhvk
mhvk deleted the time-val-to-value branch September 9, 2013 13:44
@taldcroft

Copy link
Copy Markdown
Member

Darnit, 5 minutes after merging I had the question of whether CHANGES.rst was updated with the API change here. Looks like not. @mhvk can you do that in a new quickie PR?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants