Skip to content

Fix repr is equiv simpler - #8218

Merged
bsipocz merged 5 commits into
astropy:masterfrom
eteq:fix-repr-is-equiv-simpler
Dec 5, 2018
Merged

bsipocz merged 5 commits into
astropy:masterfrom
eteq:fix-repr-is-equiv-simpler

Conversation

@eteq

@eteq eteq commented Dec 4, 2018 •

Copy link
Copy Markdown
Member

This is an alternative fix for #8138 vs #8205, as suggested by @mhvk in #8205 (review). Instead of fully defining equality for representations, it does it more narrowly only in the context of is_equivalent_frame.

Note that this should not be thought of as a full replacement for #8205. Rather, this is a bugfix to address #8138 without adding the new feature #8205 adds (a concept of representation equality). So if we opt for this, we should keep #8205 open but re-milestone it for 3.2 (and discuss there whether we really want it, since @mhvk raises some legitimate concerns).

@eteq eteq added this to the v3.1 milestone Dec 4, 2018
@eteq
eteq requested review from StuartLittlefair and mhvk December 4, 2018 08:51
@codecov

codecov Bot commented Dec 4, 2018 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@b1441f1). Click here to learn what that means.
The diff coverage is 64.28%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #8218   +/-   ##
=========================================
  Coverage          ?   86.91%           
=========================================
  Files             ?      383           
  Lines             ?    57885           
  Branches          ?     1056           
=========================================
  Hits              ?    50309           
  Misses            ?     6962           
  Partials          ?      614
Impacted Files Coverage Δ
astropy/coordinates/baseframe.py 93.43% <64.28%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1441f1...5317d64. Read the comment docs.

Comment thread astropy/coordinates/baseframe.py Resolved
Comment thread astropy/coordinates/baseframe.py Outdated
return True
elif isinstance(right_fattr, r.BaseRepresentationOrDifferential):
# both are representations. Note that this ignores any
# stored differentials

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about raising a warning if either right_fattr or left_fattr has differentials present?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go further and just return False - right now, we're even stricter and we can relax in steps.

@eteq eteq Dec 5, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the version I just pushed up I'm doing both of these things now.

I think it's important to have the warning as @StuartLittlefair suggested because otherwise it's very difficult to understand what's happening if by chance anyone gets bit by this behavior. I don't think it's relevant for any frame I've ever seen, but I think it's safer just in case because it's such a subtle thing.

Relatedly: re: @mhvk's comment, the one danger here is that it's possible we accidentally introduced a strictness here - the core problem from #8138 is that previously a lot of this could be ignored because we didn't copy representation frame attributes but rather just transferred over the references. That was not really intentional, but it masked the issue this PR is fixing. So if I'm wrong with the above and someone really is using a frame attribute with a representation that is supposed to have a differential, this might now bite them where before it was fine because it was passed by reference. I think this could be in the dictionary as a "corner case", though, so I'm not too worried. The only possibility is Sunpy... So we might want @Cadair to give a quick 👍 that this isn't used somewhere there?

@mhvk mhvk left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me modulo@StuartLittlefair's question about what to do with differentials - my tendency would be to just return False if differentials are present.

@bsipocz

bsipocz commented Dec 5, 2018

Copy link
Copy Markdown
Member

this now needs a rebase

@eteq
eteq force-pushed the fix-repr-is-equiv-simpler branch from 1e47314 to 5317d64 Compare December 5, 2018 06:31
@eteq

eteq commented Dec 5, 2018

Copy link
Copy Markdown
Member Author

Assuming the tests pass I think this is all set (i.e., I think I've addressed the discussion items) as long as @Cadair doesn't see the change discussed in #8218 (comment) doesn't break Sunpy. It does need someone to approve it though (@StuartLittlefair @mhvk @adrn?)

@bsipocz

bsipocz commented Dec 5, 2018

Copy link
Copy Markdown
Member

@Cadair - could you please double check it in sunpy?

@StuartLittlefair StuartLittlefair left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to approve this, assuming @Cadair doesn’t find it breaks SunPy

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks all fine. Good to have the warning that the behaviour with differentials may change.

@Cadair Cadair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SunPy tests pass 😄

@bsipocz
bsipocz merged commit 138b4aa into astropy:master Dec 5, 2018
@bsipocz

bsipocz commented Dec 5, 2018

Copy link
Copy Markdown
Member

Thank you all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants