Skip to content

Improve coordinate equality comparison #2154

Closed

Description

@taldcroft

As mentioned in #1832, coordinate comparisons currently just check that the internal angles and distances are the same:

>>> c1 = ICRS(1, 2, unit=['deg','deg'])
>>> c2 = FK5(1, 2, unit=['deg','deg'])
>>> c1 == c2
True

A more nuanced implementation of equality is needed, details TBD in APE5.

Activity

  1. added this to the v0.4.0 milestone on Feb 27, 2014
  2. eteq commented on Mar 25, 2014

    @eteq
    Member

    FYI, this is not explicitly addressed in the APE5 API. But my current thinking is that for low-level classes, equality means must be the same frame, all meatdata and data the same. For high-level classes it's a bit more ambiguous, but that can be addressed later. So this issue will be a reminder to get that figured out.

  3. eteq commented on May 27, 2014

    @eteq
    Member

    @taldcroft - do you consider this closed by APE5, or should we push it to 1.0 and consider changing the equality operation then?

  4. taldcroft commented on May 27, 2014

    @taldcroft
    MemberAuthor

    @eteq - from what I can tell equality comparison has gone to the other extreme of just not being implemented. Am I missing something??

    In [15]: c2 = ICRS(1*u.deg, 2*u.deg)
    
    In [16]: c1 = ICRS(1*u.deg, 2*u.deg)
    
    In [17]: c1 == c2
    Out[17]: False
    
    In [18]: c1.__eq__
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-18-b85dbdd0e83c> in <module>()
    ----> 1 c1.__eq__
    
    AttributeError: 'ICRS' object has no attribute '__eq__'
    
  5. eteq commented on May 30, 2014

    @eteq
    Member

    @taldcroft - That's right - I thought we concluded this is the safest for coordinates, given that it's ambiguous what is actually meant? It may be that's what I decided, and we didn't really talk about it, though... my memory is a bit hazy.

  6. taldcroft commented on May 31, 2014

    @taldcroft
    MemberAuthor

    I thought we were going with "equal if all data and attributes are equal" as a safe option for low-level. I do think that c2 = copy(c1); assert c1 == c2 should work for 0.4.

    What about having a coordinates.allclose method that transforms c1 into the c2 frame and checks that the sky separations are all less than a separation tolerance (angle) and the distances are the same within some rtol and atol (distance).

  7. mhvk commented on Jun 17, 2014

    @mhvk
    Contributor

    It seems this issue has become two: (1) there should be a way to test for strict equality; (2) there should be a way to test coordinates are close. I think the former should indeed exist but in practice is not very useful, while the latter will take quite a bit of work to get it really right. So, I suggest relabeling this issue to 0.4.1 to deal with equality only, and raise another for 1.0 for dealing with allclose.

  8. mhvk commented on Jun 17, 2014

    @mhvk
    Contributor

    p.s. Sorry, in case it wasn't clear from other issues: the goal is to get the list of 0.4 issues and PRs small, so that the overdue release can happen.

  9. modified the milestones: v0.4.1, v0.4.0 on Jun 22, 2014
  10. astrofrog commented on Jun 22, 2014

    @astrofrog
    Member

    @mhvk - done. This is now 0.4.1 and I opened a feature request for allclose for 1.0 (#2650)

  11. modified the milestones: v0.4.2, v0.4.3 on Sep 23, 2014
  12. embray commented on Dec 2, 2014

    @embray
    Member

    Is this still something that needs to be resolved?

  13. removed this from the v0.4.3 milestone on Dec 2, 2014
  14. bsipocz commented on Jul 31, 2017

    @bsipocz
    Member

    The original snippet is not working any more, and

    c1 = SkyCoord(1, 2, unit='deg',frame='icrs')
    c2 = SkyCoord(1, 2, unit='deg',frame='fk5')
    c1 == c2
    False
    

    so I wonder whether this can be closed now?

  15. added
    Close?Tell stale bot that this issue/PR is stale
    on Jul 31, 2017
  16. adrn commented on Sep 19, 2017

    @adrn
    Member

    I'm closing this because it is a duplicate of #3182 and I think the discussion there is more relevant now.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions