hpyproject / hpy

HPy: a better API for Python
https://hpyproject.org
MIT License
1.02k stars 52 forks source link

add a failing test to replicate numpy scalar type scheme #461

Closed mattip closed 9 months ago

mattip commented 10 months ago

This adds a test to try to recreate the NumPy DType type hierarchy. It takes the type spec from scalartypes.c.src and the double-inheritance from multiarraymodule.c to create a float64 dtype. It is locally failing to create the correct tpye heirarchy, which on NumPy is

[<class 'numpy.float64'>, <class 'numpy.floating'>, <class 'numpy.inexact'>,
 <class 'numpy.number'>, <class 'numpy.generic'>, <class 'float'>, <class 'object'>]

but in this test is only [<class 'float'>, <class 'object'>]. I am not sure why that is.

It then has two methods for creating a new float64 object: via calling, i.e. float64(n), and via using the tp_alloc slot from the PyTypeObject, like in PyArray_Scalar. This currently fails on PyPy, for a myriad of reasons, which is why I wanted a stand alone test to replicate the type creation.

Any thoughts are welcome.

mattip commented 9 months ago

Closing, the problem was elsewhere