Skip to content

CDS units are not the same as regular units #7751

Open

Description

@taldcroft

For example:

In [5]: u.s is u.Unit('s')
Out[5]: True

In [6]: u.s is u.Unit('s', format='cds')
Out[6]: False

In [7]: u.s / u.s
Out[7]: Unit(dimensionless)

In [8]: u.s / u.Unit('s', format='cds')
Out[8]: Unit("s / s")

This first came up here: #7348 (review)

Activity

  1. kyleaoman commented on Aug 21, 2018

    @kyleaoman
    Contributor

    Hm, this is even more complicated than it appears at first. Enabling cds units helps somewhat:

    >>> import astropy.units as u
    >>> u.Unit('s') is u.Unit('s', format='cds')
    False
    >>> import astropy.units.cds
    >>> with astropy.units.cds.enable():
    ...     u.Unit('s') is u.Unit('s', format='cds')
    ... 
    True
    
    

    but not entirely:

    >>> u.Unit('s') is u.s
    True
    >>> u.Unit('s', format='cds') is u.s
    False
    >>> with astropy.units.cds.enable():
    ...     u.Unit('s', format='cds') is u.s
    ... 
    False
    

    which implies the very confusing:

    >>> u.Unit('s') is u.s
    True
    >>> with astropy.units.cds.enable():
    ...     u.Unit('s') is u.s
    ... 
    False
    
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