Skip to content

TYP: double = float64 and cdouble = complex128 #29155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

jorenham
Copy link
Member

@jorenham jorenham commented Jun 9, 2025

closes #29151

Copy link

github-actions bot commented Jun 9, 2025

Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code:

pandera (https://github.com/pandera-dev/pandera)
- pandera/engines/numpy_engine.py:52: note:     def astype(self, dtype: Literal['float', 'Float32', 'Float64', 'e', 'f2', '<f2', 'float16', 'half', 'f', 'f4', 'float32', 'single', 'd', 'f8', 'float64', 'double', 'float_', 'g', 'f16', 'float128', 'longdouble', 'longfloat', 'float[pyarrow]', 'double[pyarrow]', 'float16[pyarrow]', 'float32[pyarrow]', 'float64[pyarrow]'] | type[float] | Float32Dtype | Float64Dtype | type[floating[_16Bit]] | type[floating[_32Bit]] | type[floating[_64Bit]] | type[floating[_64Bit | _96Bit | _128Bit]], copy: bool = ..., errors: Literal['ignore', 'raise'] = ...) -> Series[float]
+ pandera/engines/numpy_engine.py:52: note:     def astype(self, dtype: Literal['float', 'Float32', 'Float64', 'e', 'f2', '<f2', 'float16', 'half', 'f', 'f4', 'float32', 'single', 'd', 'f8', 'float64', 'double', 'float_', 'g', 'f16', 'float128', 'longdouble', 'longfloat', 'float[pyarrow]', 'double[pyarrow]', 'float16[pyarrow]', 'float32[pyarrow]', 'float64[pyarrow]'] | type[float] | Float32Dtype | Float64Dtype | type[floating[_16Bit]] | type[floating[_32Bit]] | type[float64] | type[floating[_64Bit | _96Bit | _128Bit]], copy: bool = ..., errors: Literal['ignore', 'raise'] = ...) -> Series[float]
- pandera/engines/numpy_engine.py:52: note:     def astype(self, dtype: Literal['complex', 'F', 'c8', 'complex64', 'csingle', 'singlecomplex', 'D', 'c16', 'complex128', 'cdouble', 'cfloat', 'complex_', 'G', 'c32', 'complex256', 'clongdouble', 'clongfloat', 'longcomplex'] | type[complex] | type[complexfloating[_32Bit, _32Bit]] | type[complexfloating[_64Bit, _64Bit]] | type[complexfloating[_64Bit | _96Bit | _128Bit, _64Bit | _96Bit | _128Bit]], copy: bool = ..., errors: Literal['ignore', 'raise'] = ...) -> Series[complex]
+ pandera/engines/numpy_engine.py:52: note:     def astype(self, dtype: Literal['complex', 'F', 'c8', 'complex64', 'csingle', 'singlecomplex', 'D', 'c16', 'complex128', 'cdouble', 'cfloat', 'complex_', 'G', 'c32', 'complex256', 'clongdouble', 'clongfloat', 'longcomplex'] | type[complex] | type[complexfloating[_32Bit, _32Bit]] | type[complex128] | type[complexfloating[_64Bit | _96Bit | _128Bit, _64Bit | _96Bit | _128Bit]], copy: bool = ..., errors: Literal['ignore', 'raise'] = ...) -> Series[complex]

colour (https://github.com/colour-science/colour)
- colour/utilities/tests/test_array.py:751: error: Incompatible return value type (got "dtype[Any]", expected "numpy.bool[builtins.bool] | signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | signedinteger[_64Bit] | unsignedinteger[_8Bit] | unsignedinteger[_16Bit] | unsignedinteger[_32Bit] | unsignedinteger[_64Bit] | floating[_16Bit] | floating[_32Bit] | float64 | complexfloating[_32Bit, _32Bit] | complexfloating[_64Bit, _64Bit]")  [return-value]
+ colour/utilities/tests/test_array.py:751: error: Incompatible return value type (got "dtype[Any]", expected "numpy.bool[builtins.bool] | signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | signedinteger[_64Bit] | unsignedinteger[_8Bit] | unsignedinteger[_16Bit] | unsignedinteger[_32Bit] | unsignedinteger[_64Bit] | floating[_16Bit] | floating[_32Bit] | float64 | complexfloating[_32Bit, _32Bit] | complex128")  [return-value]

@jorenham
Copy link
Member Author

jorenham commented Jun 9, 2025

I like the primer diffs

@jorenham
Copy link
Member Author

jorenham commented Jun 9, 2025

cc @MilanStaffehl

@jorenham
Copy link
Member Author

jorenham commented Jun 9, 2025

colour-science/colour#1353 addresses the colour diff

@charris charris merged commit ea91f18 into numpy:main Jun 11, 2025
77 checks passed
@charris
Copy link
Member

charris commented Jun 11, 2025

Thanks Joren.

@jorenham jorenham deleted the typing/gh-29151 branch June 11, 2025 18:49
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.

TYP: Inconsistent behavior when assigning arrays of a scalar type to arrays using the scalar's alias
2 participants