id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
15695,Coercion problems between numpy and sage floats,nbruin,,"See this [https://groups.google.com/forum/#!topic/sage-devel/0IalWN4NHig sage-devel thread].
This problem arises (at least on a lot of machines)
{{{
import numpy as np
sage: isinstance(np.float64(1),float)
True
sage: isinstance(np.float32(1),float)
False
sage: isinstance(np.float128(1),float)
False
sage: isinstance(np.float(1),float)
True
sage: type(np.float(1))
sage: parent(np.float64(1))
}}}
As you can see, numpy decides to map `numpy.float64` a subclass of `float`. Sage's coercion code wasn't prepared for subclassing. This leads to awkward coercion problems:
{{{
sage: 1j + np.float64(2)
2.0
}}}
(the result is of type np.float64 rather than CC, i.e., the wrong parent is chosen).
The simplest choice seems to be to ensure that sage tests for subtypes in the relevant spot.",defect,closed,major,sage-duplicate/invalid/wontfix,coercion,duplicate,,,,,Jeroen Demeyer,N/A,,,,,