pydata / numexpr

Fast numerical array expression evaluator for Python, NumPy, Pandas, PyTables and more
https://numexpr.readthedocs.io/en/latest/user_guide.html
MIT License
2.23k stars 210 forks source link

Unexpected upcasting of complex64 to complex128 #492

Closed mutricyl closed 2 months ago

mutricyl commented 4 months ago

Working on https://github.com/pandas-dev/pandas/issues/21374 I am Coming across unexpected complex128 upcasting.

here is an example of numexpr upcasting complex64 to complex128 when python operation conserves the correct dtype.

>>> compl = 1 + 1j
>>> ne.evaluate('compl + 2').dtype
dtype('complex128')
>>> ne.evaluate('compl + compl').dtype
dtype('complex128')
>>> compl+compl
(2+2j)
>>> type(compl+compl)
<class 'complex'>
>>> type(compl+2)
<class 'complex'>

Originally posted by @mutricyl in https://github.com/pydata/numexpr/issues/155#issuecomment-2147531303

github-actions[bot] commented 2 months ago

Message to comment on stale issues. If none provided, will not mark issues stale