Confirm Numpy Bug !

i’m on Win 10 Window 64 bits
and have a strange problem with Numpy complex angle value for some complex number

can some one confirm there is a bug here ?

here is code

import bpy, math 
import numpy as np
from numpy import linalg as la
from numpy import array,angle,conj,arange,matrix , exp ,deg2rad , rad2deg 
from math import *
from numpy.core.umath import deg2rad , rad2deg 


print  ('numpy version =', np.__version__)
print ()

d2r = lambda x: deg2rad(x)
r2d = lambda x: rad2deg(x)
to_rd = lambda m, d: m * exp(1j*d2r(d))
to_pd = lambda x: (abs(x), r2d(angle(x)))

print ()
print (' $$$$$$$$$$$$$$ ')
print ()


z1 = 7.49+0.71j
z2 = 127.01705922171767+0j
z3 =z2/z1
print ('z1=',z1)
print ('z1 abs =',np.absolute(z1),' z1 ang =',np.angle(z1, deg=True),' Deg')
print ('z2=',z2)
print ('z2 abs =',np.absolute(z2),' z2 ang =',np.angle(z2, deg=True),' Deg')
print ('z2/z1 = z3=',z3)
print ('z3 real =',z3.real,'z3 imag =',z3.imag)
print ()
print ('numpy     z3 abs =',np.absolute(z3),'z3 ang =',np.angle(z3, deg=True),' Deg')
print ('numpy   angle =', rad2deg(angle(z3))  )
print ()
# z3  = (16.807194052219895-1.5932053106910715j)
# q1 = np.angle(1+1j, deg=True)
print ('angle =', (angle(z3))," Rad")
#print ('angle =', rad2deg(angle(z3)) )
print ()
print ( 'z3.real =',z3.real )
print ( 'z3.imag =',z3.imag )
print ()
ang =atan(z3.imag / z3.real)
print ( 'ang =',ang ,' Rad', degrees(ang),' deg' )
print ()
print (' $$$$$$$$$$$$$$ ')
print ()

the angle for Z3 complex gives -174 deg and it should really be -5 deg see pic

thanks for feedback

happy bl


anyone can help to resolve this thing ?

happy bl

In linux the result from numpy.angle is the same as the atan. Maybe it’s just a windows thing… :frowning:

already been tested on linux and no bug there

this is why I ask to test it on win 10 64 bits

seems it is only OS dependant
but want other peoples to confirm it too
and possibly add comments to bug report

happy bl

I have tested it on Windows 7 64bit and can confirm the issue.

thanks you very much

if I give you the bug link can you add your comment there too
it will hopefully let the dev that i’m not the only one seeing this problem

but I can also give this thread as reference.

thanks again
happy bl

Sure, I have an account on Post the link and I’ll add a comment there.

should be this
don’t forget to mention the win 10 64
seems to be OS specific

thanks again