TYP: Allow passing floating, integer, and bool_ scalars to QuadPrecision.__new__#201
Conversation
…ision.__new__``
| @override | ||
| def __getitem__(self, key: Never, /) -> Self: ... # type: ignore[override] | ||
|
|
||
| # NOTE: Until `QuadPrecision` will become a subclass of `np.generic`, this class cannot |
There was a problem hiding this comment.
In [5]: issubclass(npq.QuadPrecDType().type, np.generic)
Out[5]: True
In [6]: npq.QuadPrecDType().type
Out[6]: numpy_quaddtype.QuadPrecision
In [7]: issubclass(npq.QuadPrecision, np.generic)
Out[7]: True
I think it is as Quadprecision already subclassing the np.floating
There was a problem hiding this comment.
Nice! I'll open a separate PR for that then.
There was a problem hiding this comment.
What does numpy_quaddtype.QuadPrecision.mro() return? (sorry I wasn't able to get it to build locally) Because there's a chance that there's some __subclasscheck__ trickery going on.
There was a problem hiding this comment.
In [11]: npq.QuadPrecision.mro()
Out[11]:
[numpy_quaddtype.QuadPrecision,
numpy.floating,
numpy.inexact,
numpy.number,
numpy.generic,
object]
Building it requires the numpy build from source right now :)
I think we should accept this right :) @jorenham I'll do the PR for this, you can assume it accept cc: @ngoldbaum |
floating and integer scalars to QuadPrecision.__new__floating, integer, and bool_ scalars to QuadPrecision.__new__
|
@jorenham is this ready? |
|
Also for the part that QuadPrecision is type-safe (it subclassing np.generic) |
|
Yea this is fine to merge. I want to address the np.generic subclass stuff in a follow-up, since that will probably be a bit more involved |
|
Cool thanks @jorenham merging this in |
This follows #199. See the added
# NOTEfor why we cannot annotate the array-like constructor cases.I didn't see any mention ofnp.bool_scalars in #199, only floating and integer ones. So I take it thatQuadPrecision.__new__does not acceptnp.bool_instances then?