Skip to content

Conversation

SwayamInSync
Copy link
Member

@SwayamInSync SwayamInSync commented Oct 14, 2025

closes #171

Copilot Summary

This pull request enhances the quad-precision dtype implementation for NumPy by improving type compatibility and array filling functionality. The main changes include better handling of Python numeric types for dtype promotion and discovery, and the addition of a specialized fill function for generating arithmetic progressions in quad-precision arrays.

Improved dtype compatibility and type discovery:

  • Updated common_dtype to treat Python abstract dtypes (PyLongDType, PyFloatDType) as compatible with quad-precision, ensuring correct type promotion when mixing these types.
  • Enhanced quadprec_discover_descriptor_from_pyobject to accept Python int and float objects, returning a default quad-precision descriptor, and improved error handling for unsupported types.

New array fill functionality:

  • Added a quadprec_fill function to efficiently fill quad-precision arrays with arithmetic progressions, supporting both Sleef and long double backends.
  • Registered the new fill function in the dtype's slot table, enabling NumPy to use it for array operations.

@SwayamInSync
Copy link
Member Author

NOTE: Python Abstract types are also marked type_num = -1

@juntyr
Copy link
Contributor

juntyr commented Oct 14, 2025

Could you provide a reference to the docs for the fill function?

@SwayamInSync
Copy link
Member Author

Could you provide a reference to the docs for the fill function?

Its not same as the user facing ndarray.fill(). (You can use that without this implementation and its docs available here)
The one implemented is register within dtype level as PyArray_ArrFuncs you can see the implementation for other dtype here
https://github.com/numpy/numpy/blob/46d892084f1f2ce4f6312ebbbab2d094cf216b16/numpy/_core/src/multiarray/arraytypes.c.src#L3748

Can expose the custom implementation using NPY_DT_PyArray_ArrFuncs_fill slot

@SwayamInSync
Copy link
Member Author

Can I get a review here @ngoldbaum @seberg

@seberg
Copy link
Member

seberg commented Oct 15, 2025

Promotion logic looks good to me, filling logic also, but I don't know sleef. I think my review comment is: This should have some basic tests :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: np.linspace is not supported

3 participants