Skip to content

TYP: invalid default value documented on array's ndmax parameter #30159

Closed

Description

@neutrinoceros

Describe the issue:

Hello from downstream, @jorenham !

first of: we also have a couple inspect-based tests in astropy intended to catch discrepancies between numpy signatures and our NEP 18 dispatch functions. Functions which didn't have signatures available at runtime were simply ignored, but your recent work has allowed finding many more issues with our NEP 18 implementations, so thanks a lot for that !

I'm seeing a small issue with gh-30138 though; None doesn't appear to be a valid value for array's ndmax argument at runtime (an integer is expected). Instead, and based on my understanding of gh-29569, it seems the default value should actually be 0.
It can be worked around in astropy alright, but it feels slightly off that I need to both re-expose the default value as None (granted, this part is imposed by our tests) and include logic in the implementation to handle this special case. It's also a bit awkward that the parameter is typed as int but uses None as a default.

Reproduce the code example:

# a script will not cut it

Error message:

Python and NumPy Versions:

Python 3.11.18 (irrelevant)
numpy 2.4.0dev (d8e1c8c)

Type-checker version and settings:

not actually detected at typecheck-time

Additional typing packages.

No response

Activity

  1. changed the title [-]TYP: <Please write a comprehensive title after the 'TYP: ' prefix>[/-] [+]TYP: invalid default value documented on `array`'s `ndmax` parameter[/+] on Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions