Skip to content

Move quantity to a separate sub-package - #1595

Closed
eteq wants to merge 1 commit into
astropy:masterfrom
eteq:quantity-subpackage
Closed

eteq wants to merge 1 commit into
astropy:masterfrom
eteq:quantity-subpackage

Conversation

@eteq

@eteq eteq commented Oct 17, 2013

Copy link
Copy Markdown
Member

This was @astrofrog and @mhvk's comments in #1577. Quantity has grown into an extremely convinient and powerful tool for science. But right now it lives in units, which both leaves it rather hidden in the documentation and makes it more difficult to work with. So this is a suggestion to move quantity into its own separate sub-package.

Note that if we are going to do this, we should do it now (v0.3), because Quantity is useful enough that a fair number of users already have started with it between 0.3 and the next version.

This PR is not done as there are various parts of astropy that need to be adjusted for the new location (and docs moved), but it gives a flavor for this idea. It shouldn't be too hard to finish it up quickly if we do decide to do this.

cc @mhvk @astrofrog @pllim @adrn @mdboom

@pllim

pllim commented Oct 17, 2013

Copy link
Copy Markdown
Member

I have been doing a lot of

from astropy import units as u
x = u.Quantity(...)

Is there a backward-compatibility option so the above won't break? Or will that introduce circular import between new quantity sub-package and units?

For myself, this backward compatibility is not critical. But other developers who build on astropy might also be doing the same, and this move will break their codes.

@mhvk

mhvk commented Oct 17, 2013

Copy link
Copy Markdown
Contributor

@eteq - I think you may have misunderstood my comment: I had indeed been considering whether quantity should have its own package, but I thought @astrofrog's suggestion was even better: just update the documentation, and call the documentation page "Quantities and Units". The reason for that is that I find that in practice I almost always define quatities through units, i.e., by

import astropy.units as u
v = 15. * u.km /u.s

and in the few times, I do use it directly, I do u.Quantity, like @pllim. So, if we split the package, the net effect is that I would have to import one package more, rather than one fewer.

So, overall, I'd say keep Quantity in units, update the documentation as suggested by @astrofrog in #1591, and introduce the flux sub-package that you suggested (I do think flux is a basic astronomy-related item that does not really belong in a quantity package).

@mdboom

mdboom commented Oct 17, 2013

Copy link
Copy Markdown
Contributor

👍 to all of @mhvk's comment. I think it's mainly a matter of increasing prominence of quantity within units. Quantity isn't really anything separate from units, it's just a (value, unit) container.

@eteq

eteq commented Oct 17, 2013

Copy link
Copy Markdown
Member Author

Ah, I didn't see #1591 until you mentioned it here @mhvk. So this is an alternative to that.

The advantage of a separate subpackage is that it then provides a possible place for special quantity subclasses (e.g. Distance, Angle, etc.), without mixing it in with the other unit items. That ship may have sailed already given that those already are in other subclasses, though.

@eteq

eteq commented Oct 17, 2013

Copy link
Copy Markdown
Member Author

Having seen #1591 and thought a bit more, I actually like that better as a solution... But I'll leave this for a little while in case others disagree. This can be closed once #1591 is implemented/merged.

@mdboom

mdboom commented Oct 17, 2013

Copy link
Copy Markdown
Contributor

@eteq: I think you meant #1591 in your above comment, but didn't want to edit it in case I'm just confused...

@eteq

eteq commented Oct 17, 2013

Copy link
Copy Markdown
Member Author

whoops, yeah, sorry - just edited it now. They're only one digit off, so it's easy to get confused :)

@astrofrog

Copy link
Copy Markdown
Member

I also think we should not separate them - for one, most users don't even use Quantity directly!

@pllim

pllim commented Oct 18, 2013

Copy link
Copy Markdown
Member

I actually use Quantity directly all the time but I am already used to it being inside astropy.units. 😱

@mdboom

mdboom commented Oct 18, 2013

Copy link
Copy Markdown
Contributor

At 2013-10-18 hangout, it was agreed we would follow the approach in #1591 instead of this. Closing.

@mdboom mdboom closed this Oct 18, 2013
@eteq
eteq deleted the quantity-subpackage branch May 3, 2015 17:18
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.

5 participants