Skip to content
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

Fix construction of HG frames to be 3D #3351

Merged
merged 6 commits into from
Oct 21, 2019
Merged

Conversation

Cadair
Copy link
Member

@Cadair Cadair commented Sep 12, 2019

Fixes #3350

@ghost
Copy link

ghost commented Sep 12, 2019

Thanks for the pull request @Cadair! Everything looks great!

@Cadair Cadair requested a review from a team September 12, 2019 15:26
@Cadair Cadair added this to the 1.0.4 milestone Sep 12, 2019
@ayshih ayshih added the coordinates Affects the coordinates submodule label Sep 12, 2019
@ayshih
Copy link
Member

ayshih commented Sep 16, 2019

While this PR does fix the issue, I suspect that there might be a better/cleaner way to fix it. Or I could just be imagining things. I'd like to do some tinkering before letting this through, unless a bugfix release is just around the corner.

@Cadair
Copy link
Member Author

Cadair commented Sep 16, 2019

@ayshih It's not the end of the world if this floats for a little while, but it is breaking me messing around with #3353.

I thought a decent amount about this, and I am pretty sure this is the best way. When you construct the frame with an explict SphericalRepresentation it seems to me the only logical thing to do is to throw it through our code to add R.

@ayshih
Copy link
Member

ayshih commented Oct 2, 2019

I just PR-ed to your branch. After poking around a bunch, I've decided that the whole approach to keyword checking and represent_as was unnecessarily complicated. (The represent_as stuff is my fault.) Instead it will now always upgrade to 3D, as already promised in the docstring. If a user chooses to specify a representation_type of UnitSphericalRepresentation, that's what they'll be shown, with component attributes to match, but the underlying data will be 3D.

Simpler approach to ensuring that HGS/HGC frames are always 3D
@pep8speaks
Copy link

pep8speaks commented Oct 2, 2019

Hello @Cadair! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 225:13: E129 visually indented line with same indent as next logical line

Comment last updated at 2019-10-19 12:40:26 UTC

@Cadair
Copy link
Member Author

Cadair commented Oct 12, 2019

Do the changes to the represent_as function have any effect here? Is this still just a bug fix?

@ayshih
Copy link
Member

ayshih commented Oct 15, 2019

In terms of user-facing API, the change here is what .data returns. Previously, if a user specifically defined the representation_type, the class would try to preserve the underlying data and its representation, even if it was 2D rather than 3D. The .represent_as() stuff was there so that the class was still able to work with the underlying data as if it were 3D. Thus, previously, .data could still return a 2D representation, although this behavior was entirely undocumented. (The bug identified in the corresponding issue was because the SkyCoord machinery can specify a representation_type that is different from the type of the representation.) I think this still qualifies as a bug fix because these shenanigans were in violation of the docstring, which says that the data will always be converted to 3D.

@Cadair
Copy link
Member Author

Cadair commented Oct 15, 2019

Could you perhaps suggest some appropriate wording for the changelog just to make that obvious to everyone? (or I can and then you can comment on it?)

@ayshih
Copy link
Member

ayshih commented Oct 17, 2019

Here's a wordier version:

Fixed situations where 2D coordinates provided to `~sunpy.coordinates.frames.HeliographicStonyhurst` and `~sunpy.coordinates.frames.HeliographicCarrington` were not converted to 3D as intended.  Furthermore, the stored data will always be the post-conversion, 3D version.

changelog/3351.bugfix.rst Outdated Show resolved Hide resolved
@Cadair Cadair merged commit 46cfe66 into sunpy:master Oct 21, 2019
@Cadair Cadair deleted the frame_fix branch October 21, 2019 13:52
@backporting
Copy link

backporting bot commented Oct 21, 2019

The backport to 1.0 failed:

Commits ["956d96258d1b011ef036378304b65fb643c31571","87e96ae32e273b89e1eec18364d6f025f8ea7d8c","b13422b36a587ff992bf07cd630dbb61ed1b0da4","d9eb5e846b3c3eaa73f142e3ea000918745d5560","85114e9928a2f1347c18107ee929232189bda559","96b1301a575aa5ea22df2486da8322341f4ea56a"] could not be cherry-picked on top of 1.0

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub.
git fetch
# Create new working tree.
git worktree add .worktrees/backport 1.0
# Navigate to the new directory.
cd .worktrees/backport
# Cherry-pick all the commits of this pull request and resolve the likely conflicts.
git cherry-pick 956d96258d1b011ef036378304b65fb643c31571 87e96ae32e273b89e1eec18364d6f025f8ea7d8c b13422b36a587ff992bf07cd630dbb61ed1b0da4 d9eb5e846b3c3eaa73f142e3ea000918745d5560 85114e9928a2f1347c18107ee929232189bda559 96b1301a575aa5ea22df2486da8322341f4ea56a
# Create a new branch with these backported commits.
git checkout -b backport-3351-to-1.0
# Push it to GitHub.
git push --set-upstream origin backport-3351-to-1.0
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport

Then, create a pull request where the base branch is 1.0 and the compare/head branch is backport-3351-to-1.0.

@Cadair Cadair added the Still Needs Manual Backport This PR needs manually backporting. label Oct 21, 2019
@Cadair
Copy link
Member Author

Cadair commented Oct 22, 2019

Point of order, it seems that this backport failed because of the merge commit.

@Cadair Cadair removed the Still Needs Manual Backport This PR needs manually backporting. label Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coordinates Affects the coordinates submodule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a HeliographicStonyhurst frame with SkyCoord does not always return a 3D frame
3 participants