hgrecco / pint-pandas

Pandas support for pint
Other
169 stars 42 forks source link

30 units on 950 are silently returning wrong result on comparison operation #122

Closed arkanoid87 closed 1 year ago

arkanoid87 commented 2 years ago

Seems somehow linked to angular units but yet to find out the reason behind this

for unit in c.ureg:
    try:
        bar = pd.DataFrame({"foo": c.PA_([0.0,1.0,2.0], unit)})
        if (bar["foo"] > 1).sum() == 0:
            print(unit)
    except:
        pass

output:

K_alpha_Mo_d_220
K_alpha_W_d_220
alpha
angular_degree
angular_minute
angular_second
arc_minute
arc_second
arcdeg
arcdegree
arcmin
arcminute
arcsec
arcsecond
deg
degree
electron_g_factor
fine_structure_constant
g_e
gon
grad
grade
mas
mil
milliarcsecond
sq_deg
sqdeg
square_degree
tansec
α
andrewgsavage commented 2 years ago

I suspect it's interpreting the 1 in 'if (bar["foo"] > 1).sum() == 0:' as radians. That's a pint issue.