Skip to content

Conversation

@SwayamInSync
Copy link
Member

@SwayamInSync SwayamInSync commented Oct 27, 2025

This PR is a part of work, where making numpy_quaddtype compatible with NumPy's longdouble tests

Copilot Summary

This pull request adds robust string and file parsing support for the quad-precision NumPy dtype, enabling users to reliably load and save quad-precision arrays using text-based methods such as np.fromstring and np.fromfile. The changes include new C implementations for parsing from strings and files, integration of these functions into the dtype definition, and comprehensive test suites to verify parsing accuracy and edge case handling.

Quad-precision parsing functionality:

  • Added quadprec_scanfunc and quadprec_fromstr C functions to parse quad-precision values from files and strings for both Sleef and native backends (quaddtype/numpy_quaddtype/src/dtype.c).
  • Registered the new parsing functions with the NumPy dtype system by adding them to QuadPrecDType_Slots (quaddtype/numpy_quaddtype/src/dtype.c).
  • Included <ctype.h> for whitespace handling in parsing routines (quaddtype/numpy_quaddtype/src/dtype.c).

Testing and validation:

  • Added TestStringParsing and TestFileIO classes with extensive tests for string and file parsing, covering simple values, high precision, scientific notation, negative values, separators, roundtrips, empty files, and edge cases (quaddtype/tests/test_quaddtype.py).

Copy link
Contributor

@juntyr juntyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - does this need a stubs adjustment?

@SwayamInSync
Copy link
Member Author

LGTM - does this need a stubs adjustment?

Test seem to pass, so maybe not. Maybe because these are already defined numpy array functions and here I just provided the inline C implementation

@SwayamInSync
Copy link
Member Author

Merging this in

@SwayamInSync SwayamInSync changed the title ENH: Adding Support for scanfunc and fromstr ArrayFunc FEAT: Adding Support for scanfunc and fromstr ArrayFunc Oct 28, 2025
@SwayamInSync SwayamInSync merged commit 48d2f42 into numpy:main Oct 28, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants