Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jorenham
Copy link
Member

@jorenham jorenham commented Nov 15, 2025

The following masked wrapper functions are now transparent w.r.t. their wrapped runtime signature (inspect.signature), and are now function types (types.FunctionType) instead of instances of one of the numpy.ma.extras._fromnxfunction classes:

  • ma.atleast_1d
  • ma.atleast_2d
  • ma.atleast_3d
  • ma.vstack, ma.row_stack
  • ma.hstack
  • ma.column_stack
  • ma.dstack
  • ma.stack
  • ma.hsplit
  • ma.diagflat

Stubtest now recognizes these as actual functions, so that they can now be meaningfully annotated in the stubs, without stubtest complaining about it.

To illustrate; running np.ma.stack? in an IPython console used to show

Signature:       np.ma.stack(x, *args, **params)
Type:            _fromnxfunction_seq
String form:     <numpy.ma.extras._fromnxfunction_seq object at 0x7161fe17a3f0>
File:            ~/.local/share/uv/tools/ipython/lib/python3.14/site-packages/numpy/ma/extras.py
Docstring:      
Join a sequence of arrays along a new axis.
[...]

which now looks like this:

Signature: np.ma.stack(arrays, axis=0, out=None, *, dtype=None, casting='same_kind')
Docstring:
Join a sequence of arrays along a new axis.
[...]

Comment on lines -137 to -147
# TODO: remove/deprecate once `ma.extras._fromnxfunction.getdoc` no longer uses it
def get_object_signature(obj):
"""
Get the signature from obj
"""
try:
sig = formatargspec(*getargspec(obj))
except TypeError:
sig = ''
return sig
Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW; I wasn't able to find anyone that used this on github code search

@jorenham jorenham added this to the 2.4.0 release milestone Nov 16, 2025
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.

1 participant