-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
table: change 'units' to 'unit' #1174
Conversation
No anger from me. 😉 Haven't really read this line-by-line, but I agree in principle. I know that saying "the units of a value" is common English usage, but in code, I generally don't like to see plural unless something is a collection of something. |
If we do this we should probably deprecate this properly so that it doesn't break in 0.3. Is this the only place the plural appears? |
I'm OK with this, but I do think there should be a deprecation release. Maybe we can make a There are a number of I'm not sure what you mean about a bunch of tests also failing on master. I didn't do a comprehensive scan, but the first five failures in the Travis output were all about a Column object not having a |
Once we are at it, I also suggest changing I think it would be good to do all changes Plural -> Singular in one PR, that's why I bring it up here, even if it does not strictly fit under the title of this issue. |
I'm fine with the change to @hamogu - I think a monolathic change of doing all plural -> singular throughout astropy is a bit tough because it would touch a lot of different files and lead to many other PRs needing to be rebased (or do you mean just in |
Yes, I agree, maybe not everywhere, but everywhere in table - let's |
Great, ok, so my action item is to add |
All you have to do is make units a property that returns |
Hm, not getting a |
Ah, right, so Python 2.7 hides |
@adrn - yeah, I think that's a little bit silly given that most users will therefore get no warning and things will suddenly break. |
Made the change from dtypes -> dtype too. |
@astrofrog I agree. I've been thinking for a while of ensuring that Deprecation Warnings are displayed by default, even on Python 2.7. This can just go somewhere in |
Strictly speaking the
Now maybe the above errors should be fixed, but as-designed there was a specific reason for |
Interestingly pandas takes a
Basically pandas is doing something weird relative to what I'd expect from numpy array. |
My point here was the comparison with numpy.rec.arrays, where it is also |
In the end I agree we should probably change |
@adrn - every function or class initializer that previously accepted The basic plan is that you need to add back the old (plural) keyword arg at the end of the argument list. If that is specified by name in the call then set Maybe we could make some sort of keyword argument change decorator that handles the deprecation warning and the argument swap. I guess a decorator could be a good thing also because (I think) we could really hide the fact in the call signature and docs that the plural form is still an acceptable keyword arg. So you would do
@iguananaut - do you know of any available decorators that would fit this bill? It actually seems like a generic thing that has probably already been invented. |
Ah, right -- deprecated the attributes but forgot about the kwargs. |
I don't have anything like that on hand for arguments. When I've needed to do that (rarely) I've just hand-coded it the function. |
Ok, I think I added the plural kwargs back where necessary, and I added some tests to make sure they raise |
Rebased on master. |
@iguananaut any idea why the build is failing? can't make any sense of that... |
@adrn - I think this is unrelated to your changes and is some Travis quirk with the parallel testing. I just restarted the last set of tests and hopefully that'll do it. Quick note: there should probably be an entry in the changelog about this. Maybe also add this to the section about API breaking, indicating that the API isn't going to break in this version, but will in the next? |
Cool, done! |
Argh, docs bug...how is such a simple PR such a hassle :) |
@adrn - the issue is in CHANGES.rst:
There were also a few other failed builds, but I don't think that's related to this pull request. |
@adrn - just one final check that you grepped the entire doc tree for units and there were no remaining instances that need to be changed. Otherwise looks good to me, thanks for opening this can of worms and getting it closed again! |
@astrofrog thanks for the direct pointer! @taldcroft ok, double checked and found a few that I forgot to change! fixed. |
As noted before, build failures are unrelated. |
This reverts commit 92629ac.
Someone merge this before I have to rebase again :) |
@taldcroft - good to merge? |
@@ -486,7 +486,7 @@ def t(self): | |||
|
|||
def test_add_none_to_empty_table(self, table_types): | |||
self._setup(table_types) | |||
t = table_types.Table(names=('a', 'b'), dtypes=('i', 'S4')) | |||
t = table.Table(names=('a', 'b'), dtype=('i', 'S4')) |
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.
I think this somehow got changed from table_types
(the fixture that does Masked and Unmasked tables) to the plain table
(package).
Other than the change above with |
Oh yea, that's weird... fixed! |
Build failure due to network failure I think? |
Well this is probably as close as this will get to success... there is a travis build failure unrelated to testing. Everything else passed, so I'm merging. |
table: change 'units' to 'unit' and 'dtypes' to 'dtype'
Thanks @adrn, hopefully you've learned your lesson to never become owner of an issue like this again. 😸 |
Sorry to just be getting to this now -- I could have saved everyone a lot of grief: There is a helper function in See #1265. |
@mdboom - can you please not go on vacation in the future. :-) |
I suspect this will make some people angry, but we need to decide on plural or singular. My vote goes for singular, and that's what we decided on for
Quantity
and incoordinates
. I've changed all theunits
instances tounit
(where appropriate).