Add numpy dtype access for TypeValue #738
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #737
Motivation
TypeValueobjects to the corresponding NumPydtypeto aid interoperability (buffers/array conversions).Description
@property__numpy_dtype__onTypeValue(insrc/JlWrap/type.jl) that importsnumpyand returnsnumpy.dtype(...)for the basicBool,Int*,UInt*,Float*,Complex{Float*}(where supported) andPtr{Cvoid}types.ComplexF16(Complex{Float16}) is not mapped because NumPy does not support acomplex32alias here, so it is intentionally left unsupported.AttributeErrorfrom__numpy_dtype__.pytestcoverage inpytest/test_all.pyverifying correct dtype mappings and that unsupported types (e.g.ComplexF16,String) raiseAttributeError.Testing
julia --project -e 'using Pkg; Pkg.test()', which completed successfully (registry update produced a warning but tests passed).julia --project -e 'using Pkg; Pkg.test(coverage=true)', which completed successfully (registry update warning reported).uv run pytest -s --nbval ./pytest; an initial failure surfaced (NumPy does not accept a"complex32"alias), the implementation and tests were adjusted, and the finaluv run pytest -s --nbval ./pytestcompleted with19 passed.uv run pytest -s --nbval --cov=pysrc ./pytest, which completed successfully and reported the Python-side coverage summary (overallpysrccoverage reported by the run).Codex Task