-
-
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
Smart formatting of tick labels in WCSAxes #7215
Conversation
Hi there @astrofrog 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. I noticed the following issue with this pull request:
Would it be possible to fix this? Thanks! If there are any issues with this message, please report them here. |
5c9d547
to
0741eef
Compare
Does it make any sense to add |
@Cadair - with this PR, you can use |
Nice! |
At least that's the theory ;) Feel free to try it out! |
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.
How would this code work with plots that have axes that are angle offsets rather than absolute angles?
return self._format_unit | ||
|
||
@format_unit.setter | ||
def format_unit(self, unit): |
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.
Could the setter also take a string like 'hourangle' or 'deg'?
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.
Yep, I've updated this and set_format_unit
to accept anything that can initialize Unit
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 to me!
@@ -109,6 +109,9 @@ def test_contour_overlay(self): | |||
ax.set_xlim(0., 720.) | |||
ax.set_ylim(0., 720.) | |||
|
|||
# For backward-compatibility with previous reference images |
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.
Maybe explain in this comment what change required this?
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.
Done
This code will only enable hh:mm:ss notation if CTYPE[:4] is |
@astrofrog - If this is an enhancement rather than a bugfix, ultimately it should be 3.1 rather than 3.0.1 isn't it? |
@bsipocz - I think it's a borderline case - see my comment at the top of this PR:
I'm happy to re-milestone this to 3.1 though as I don't feel strongly about it. |
@astrofrog - I'm just playing the gatekeeper role with no real preference, and I'm actually happy to backport borderline cases if anyone makes a decision about them. |
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, @astrofrog. LGTM except for a couple minor comments.
It's borderline, but let's leave this as 3.0.1
.
|
||
if not isinstance(values, u.Quantity) and values is not None: | ||
raise TypeError("values should be a Quantities array") | ||
|
||
if len(values) > 0: | ||
|
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.
Why the blank line?
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.
Fixed
---------- | ||
value : float | ||
The value to format | ||
format : { 'auto' | 'ascii' | 'latex' }, optional |
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.
nitpick: shouldn't this be a comma-separated list (that's what numpydoc uses) instead of pipe-separated?
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.
Fixed
LGTM. Thanks, @astrofrog. This will need to be rebased once #7234 is merged. |
8a7eccf
to
a9966bb
Compare
a9966bb
to
1f2075e
Compare
…ault. This also generalizes the AngleFormatterLocator so that it can take default units as well as having a way to specify to use decimal formatting by default.
… take string units
@larrybradley I just rebased this in the hopes that it can be merged in the near future. |
There are real test failures due to @Cadair's commit :) I need to investigate and fix them, I'll try and take a look now. |
fmt = None | ||
|
||
decimal = False | ||
sep = 'fromunit' |
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.
@Cadair - can you explain this change? Why set decimal to False here and then change sep when it was set to None on line 354?
1f2075e
to
32f6038
Compare
Since this PR was functional and approved prior to @Cadair's commit, I've removed that commit and will add it (and fix the failures) in a separate PR. |
It looks like I moved this to 3.1 in the last commit before merging, but the astropy bot didn't have time to catch the inconsistency in the milestone. I'm going to change the milestone to 3.1 as I don't really feel strongly that this really should be backported and these are non-trivial changes. |
This fixes the formatting of tick labels when used with a right ascension axis, in which case the hh:mm:ss format should be used (not dd:mm:ss). This is done by making it so that
AngleFormatterLocator
takes aformat_unit
(likeScalarFormatterLocator
). This also fixes the use ofset_format_unit
with angle coordinates.This is a bordeline bug/enhancement case, but I'd argue that the fact that
set_format_unit
didn't work correctly for angle coordinates previously was a bug.Here's what an RA/Dec plot now looks like by default:
Remaining to-dos:
Fixes #7209