Skip to content

Setting Quantity item inconsistent #2959

Description

@wkerzendorf

As expected

In [42]: test = np.arange(1000) * u.km

In [43]: test[300] = 1000
ERROR: UnitsError: '' (dimensionless) and 'km' (length) are not convertible [astropy.units.quantity]

UnitsError: '' (dimensionless) and 'km' (length) are not convertible

but

In [44]: test[300] = 0.0

In [45]: test[300]
Out[45]: <Quantity 0.0 km>

@mhvk any ideas?

Activity

  1. astrofrog commented on Sep 19, 2014

    @astrofrog
    Member

    @wkerzendorf - I think this is intentional behavior, in the sense that 0 is pretty unambiguous - it doesn't matter what unit system it's in (with the exception of celsius/fahrenheit), 0 m is the same as 0 km etc. It doesn't mean we can't decide to change it, but I'm pretty sure this is intentional, not a bug.

  2. mdboom commented on Sep 19, 2014

    @mdboom
    Contributor

    The relevant PR is #1254.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions