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

Fixed WCS.wcs.cunit equality #9154

Merged
merged 4 commits into from
Aug 22, 2019
Merged

Fixed WCS.wcs.cunit equality #9154

merged 4 commits into from
Aug 22, 2019

Conversation

MSeifert04
Copy link
Contributor

@MSeifert04 MSeifert04 commented Aug 21, 2019

When the first item was the same the previous approach considered them equal and didn't check the following items.

Also removed the comparison of unit_class since that's just the astropy.units.Unit class and shouldn't be relevant for equality. Maybe that reference should not be kept in the instances but rather as static reference but that's something that can be addressed in the future and is not appropriate to change in a bug-fix commit.

When the first item was the same the previous approach
considered them equal and didn't check the following
items.

Also removed the comparison of unit_class since that's
just the astropy.units.Unit class and shouldn't be
relevant for equality. Maybe that reference should not
be kept in the instances but rather as static reference but
that's something that can be addressed in the future and
is not appropriate to change in a bug-fix commit.
@MSeifert04 MSeifert04 added the Bug label Aug 21, 2019
@MSeifert04 MSeifert04 added this to the v3.2.2 milestone Aug 21, 2019
@MSeifert04 MSeifert04 requested a review from nden August 21, 2019 16:27
@astropy-bot astropy-bot bot added the wcs label Aug 21, 2019
@MSeifert04
Copy link
Contributor Author

Just as an aside: I found this bug because of a compiler generated warning that looked very suspicious:

astropy/wcs/src/unit_list_proxy.c:210:34: warning: incompatible pointer types
      passing 'char (*)[72]' to parameter of type 'const char *'
      [-Wincompatible-pointer-types]
  equal = equal == 1 && !strncmp(lhs->array, rhs->array, ARRAYSIZE) && l...
                                 ^~~~~~~~~~

And I somehow overlooked this in #8480.

@MSeifert04 MSeifert04 changed the title Fixed cunit equality test Fixed WCS.wcs.cunit equality Aug 21, 2019
if (equal == -1) {
return NULL; // Exception will be set because the rich-compare failed

{
Copy link
Member

Choose a reason for hiding this comment

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

That is this { tied to? Seems to be orphaned. Am I reading this right?

Copy link
Contributor Author

@MSeifert04 MSeifert04 Aug 21, 2019

Choose a reason for hiding this comment

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

Yep, it's orphaned. It's a so called "nested scope" (it creates a new scope for variables). I used it here to separate the code dealing with the pre-condition checks and the actual comparison.

If that's confusing I can remove it again - it's not necessary here.

Copy link
Member

Choose a reason for hiding this comment

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

If it is not strictly necessary, I would vote to remove it. Or at least state the intention of the block. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay 👍

@MSeifert04
Copy link
Contributor Author

Cc @astrofrog (original issue)

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! I wonder whether this should be backported to LTS - maybe @bsipocz can advise?

@MSeifert04
Copy link
Contributor Author

MSeifert04 commented Aug 22, 2019

On my phone currently - but i think the patch adding the eq was added in 3.2 so no need to backport?

@MSeifert04
Copy link
Contributor Author

Thank you for the review! 👍

@pllim
Copy link
Member

pllim commented Aug 22, 2019

#8480 was indeed milestoned for 3.2. Thanks!

@pllim pllim merged commit c080de4 into astropy:master Aug 22, 2019
@nden
Copy link
Contributor

nden commented Aug 22, 2019

@pllim I wish you could give me a chance to review before my merging WCS PRs.

@MSeifert04 MSeifert04 deleted the wcs-cunit-equality-fix branch August 22, 2019 14:57
@pllim
Copy link
Member

pllim commented Aug 22, 2019

@nden , I deeply apologize and I take full responsibility!

@MSeifert04
Copy link
Contributor Author

@nden In case you have some comments or questions regarding the changes I'll still answer or address them. Just let me know :)

@nden
Copy link
Contributor

nden commented Aug 23, 2019

@MSeifert04 I'm sure you will :) . I just want to be aware of what is happening in the package without feeling I'm in a race. Thanks for the contributions!

bsipocz pushed a commit that referenced this pull request Sep 9, 2019
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.

None yet

4 participants