Skip to content

Conversation

sarlinpe
Copy link
Contributor

@sarlinpe sarlinpe commented Aug 11, 2025

  • Copied tests from v2.13 and updated for the changes introduced by v3.0.0
    • int -> typing.SupportsInt and similarly for float
    • set/list/dict and generic types in typing -> collections.abc equivalent
  • Unified the parsing of annotation strings in FixNumpyArrayDimTypeVar and FixNumpyArrayDimAnnotation to handle both old-style (pre-v3.0.0) and new-style annotations.
    • old-style: np.ndarray[PRIMITIVE_TYPE[*DIMS], *FLAGS]
    • new-style:
      typing.Annotated[numpy.typing.ArrayLike, PRIMITIVE_TYPE, "[*DIMS]", "*FLAGS"]
      typing.Annotated[numpy.typing.NDArray[PRIMITIVE_TYPE], "[*DIMS]", "*FLAGS"]
      typing.Annotated[numpy.typing.ndarray[Any, PRIMITIVE_TYPE], "[*DIMS]", "*FLAGS"]
      typing.Annotated[typing.Annotated[NDArray[...]], "[m, n]", "*FLAGS"]
  • Handle again the deprecated numpy.bool dtype since v3.0.0 apparently uses it (instead of the native bool)
  • Fix a bug resulting in parse_annotation_str not being called on the first nested level of a union, thereby breaking the parsing of Union[Annotated[numpy...], None]
  • Check test errors with --numpy-array-wrap-with-annotated since v3.0.0 does not anymore throw errors on missing import for dynamic shape variables.

Unrelated to v3.0.0 but necessary to run tests locally: ensure the tests are built with the correct C++ standard

These fixes have been working well for us at https://github.com/colmap/colmap

Fixes #264

@sarlinpe sarlinpe force-pushed the sarlinpe/test-v3.0.0 branch from 8e8a70c to 8396e1e Compare August 17, 2025 10:35
@sarlinpe sarlinpe force-pushed the sarlinpe/test-v3.0.0 branch 2 times, most recently from f0a4df0 to 63f0a13 Compare August 17, 2025 14:10
@sarlinpe sarlinpe force-pushed the sarlinpe/test-v3.0.0 branch from 63f0a13 to 06f204f Compare August 17, 2025 14:11
@sarlinpe sarlinpe changed the title Add tests for Pybind v3.0.0 Fix numpy annotations for for pybind v3.0.0 Aug 17, 2025
@sarlinpe sarlinpe marked this pull request as ready for review August 17, 2025 14:17
@sarlinpe sarlinpe changed the title Fix numpy annotations for for pybind v3.0.0 Fix numpy annotations for pybind v3.0.0 Aug 17, 2025
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.

numpy-array-use-type-var is broken with pybind11 v3.0.0
1 participant