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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Move _get_converter to public API #16139
Conversation
Thank you for your contribution to Astropy! 馃寣 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
astropy/units/function/core.py
Outdated
@@ -230,6 +230,9 @@ def is_equivalent(self, other, equivalencies=[]): | |||
|
|||
return self.physical_unit.is_equivalent(other_physical_unit, equivalencies) | |||
|
|||
# def get_converter(self, other, equivalencies=[]): | |||
# pass | |||
|
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.
Currently FunctionUnitBase
does not expose the get_converter
method, and I guess they should for consistency. u.Jy.get_converter(u.ABmag)
works but u.ABmag.get_converter(u.Jy)
doesn't.
If we do end up going forward with this PR should I add the functionality in this PR or create a new one?
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.
Good point. Essentially, the logic is all in to()
, so that would need to be changed. My sense is that you have a nice & easy PR here, so do this as follow-up!
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.
Perfect! I will create a new PR for that change.
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.
thanks! This looks good - really just nitpicks about the new docstring...
Also, since this is now public API, we probably should have some explicit tests. I wonder if there were some when we reverted it... If not, I'd suggest the very simple one you have as an example, as well as one involving equivalencies (say, u.parallax()
) and one going to ABmag
. They may be most logical in different test files...
astropy/units/function/core.py
Outdated
@@ -230,6 +230,9 @@ def is_equivalent(self, other, equivalencies=[]): | |||
|
|||
return self.physical_unit.is_equivalent(other_physical_unit, equivalencies) | |||
|
|||
# def get_converter(self, other, equivalencies=[]): | |||
# pass | |||
|
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.
Good point. Essentially, the logic is all in to()
, so that would need to be changed. My sense is that you have a nice & easy PR here, so do this as follow-up!
Since you pointed it out above, it does revert something that was intentional: That was put in to address this problem: So, you have to make sure the very old Issue 3456 is not resurfacing here. Thanks! |
Good suggestion! @MridulS - I just read through the original issue and there were some specific wording changes suggested there. |
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.
Looks good! There are readthedocs failures, though, see in line comment. Also a suggestion for a bit more explanation in the changelog fragment.
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.
OK, all good now, let's get this in!
Description
This PR fixes #9080, fixes #8273, fixes #11206. It almost just reverts the 9 year old commit 55022e9 馃槃
With this in the public API something like this would be supported behaviour:
This does speed up the examples in the issues.