Callable mag, dex, dB units, and parsing of such units.#3618
Callable mag, dex, dB units, and parsing of such units.#3618mdboom merged 9 commits intoastropy:masterfrom
Conversation
|
I haven't looked at the code, but I like the concept! |
|
Note to self: if we do this, |
|
Set the 1.10 milestone, since I think with this merged, the preferred API for function units changes: one would do |
3a50d38 to
442a18a
Compare
|
@mdboom - here's an update on the callable units. It now makes I'll try to update the documentation later today. |
astropy/units/function/mixin.py
Outdated
There was a problem hiding this comment.
I think reusing the same name here is a bit confusing (when used in the function/units.py file below). Maybe call it IrreducibleFunctionUnit. Same for FunctionUnit below...
|
Looks good other than my one minor comment. |
|
@mdboom - OK, changed those names. I now also updated the documentation, including giving a little teaser in the "getting started" section of units. |
5b9dc67 to
6c4a71b
Compare
Lets functions be interpreted as units if not followed by a parenthesis.
E.g., 'Unit("mag(ct/s)")'
Also allow latex format.
(Rather than explicit MagUnit, etc.)
Since Quantity.__div__ already calls __truediv__ instead of the other way around.
|
@mdboom - I think this is now all done (I now use the callable units in the parser and resolved a small issue found while testing with |
Callable mag, dex, dB units, and parsing of such units.
EDIT -- now rewritten such that one just does
u.mag(u.ct/u.s), whereu.magis a standard unit that has a__call__method.ORIGINAL TEXT:
Just as a proof of concept, this allows one to do, e.g.,
To be useful, it would imply using the function unit
magas the default instance foru.mag. This would require more work.