Skip to content

Unexpected side effect using numpy trig functions #399

@josiahslack

Description

@josiahslack

I ran across this yesterday.

I type the following into a python REPL:

`
import numpy as np
import pint

ureg = pint.UnitRegistry()
Q_ = ureg.Quantity
theta = Q_(30, ureg.degrees)
type(theta.m) # returns int
s_theta = np.sin(theta)
type(theta.m) # returns numpy.ndarray
`
Printing theta, using comparisons, etc. doesn't show that anything has changed about it. I ran into trouble when I was saving an angle's magnitude to a JSON file, and json.dump complained that it didn't know how to write 'array(0.0)'. I worked backwards, and eventually isolated the point where the type of the angle's magnitude changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    numpyNumpy related bug/enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions