Skip to content

np.rad2deg #139

Open
Open

Description

@CJ-Wright
Traceback (most recent call last):
  File "/home/christopher/mc/envs/hw/lib/python3.5/site-packages/quantities/quantity.py", line 231, in __array_prepare__
    res._dimensionality = p_dict[uf](*objs)
KeyError: <ufunc 'rad2deg'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/media/christopher/DATA/academics/xray/ps4/problem1.py", line 19, in <module>
    print(np.rad2deg(theta))
  File "/home/christopher/mc/envs/hw/lib/python3.5/site-packages/quantities/quantity.py", line 236, in __array_prepare__
    """ % uf
ValueError: ufunc <ufunc 'rad2deg'> not supported by quantities
                please file a bug report at https://github.com/python-quantities

Activity

  1. twmr commented on Aug 20, 2019

    @twmr
    Contributor

    @CJ-Wright Why do you want to pass a quantity to rad2deg instead of using .rescale ?

  2. CJ-Wright commented on Aug 20, 2019

    @CJ-Wright
    Author

    Fair point, although I think it would be good to handle this case if possible, since functions that quantities are being passed to may not be aware that the data being passed in is a quantity and so use rad2deg.

  3. added
    bug
    on Nov 17, 2026
  4. added this to the 0.18.0 milestone on Nov 17, 2026
  5. added
    numpy-integration
    on Nov 17, 2026
  6. OmkarGowda990 commented on Nov 20, 2026

    @OmkarGowda990

    I'd like to work on this. It still happens on quantities 0.17.0: np.rad2deg(1*pq.rad) and np.deg2rad(180*pq.deg) raise ValueError: ufunc ... not supported by quantities, while np.degrees and np.radians already work and return deg and rad.

    Since rad2deg and deg2rad are NumPy's aliases for degrees and radians, my plan is to register them with the same handling, with tests. Would that be OK?

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

    bugnumpy-integration

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions