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

Skip to content

BUG: static typing of numpy.clip seems to be missing some kwargs #24391

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

Closed
pedro-w opened this issue Aug 11, 2023 · 2 comments · Fixed by #24611
Closed

BUG: static typing of numpy.clip seems to be missing some kwargs #24391

pedro-w opened this issue Aug 11, 2023 · 2 comments · Fixed by #24611

Comments

@pedro-w
Copy link

pedro-w commented Aug 11, 2023

Describe the issue:

Using the 'basic type checking' option in VS code I see an error flagged on a numpy call which I believe to be incorrect. I originally posted a bug for pyright and they told me to ask here, as VS code's typing info for numpy comes from the project itself.

Reproduce the code example:

import numpy

numpy.clip(numpy.zeros(1), 0, 255, casting='safe')

Error message:

No overloads for "clip" match the provided arguments
    Argument types: (NDArray[float64], Literal[0], Literal[255], Literal['safe'])

Runtime information:

1.25.2
3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
WARNING: `threadpoolctl` not found in system! Install it by `pip install threadpoolctl`. Once installed, try `np.show_runtime` again for more detailed build information
[{'numpy_version': '1.25.2',
  'python': '3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 '
            '64 bit (AMD64)]',
  'uname': uname_result(system='Windows', node='LAPTOP', release='10', version='10.0.22621', machine='AMD64')},
 {'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2'],
                      'not_found': ['AVX512F',
                                    'AVX512CD',
                                    'AVX512_SKX',
                                    'AVX512_CLX',
                                    'AVX512_CNL',
                                    'AVX512_ICL']}}]
None

Context for the issue:

This issue is cosmetic in the sense that the code will run correctly even if the error shows in the editor.

However if you agree that it looks like the root cause is in the numpy project, I am happy to do a bit more investigation to see if it affects other ufuncs and other keyword args, and hopefully generate a PR to fix everything.

@BvB93
Copy link
Member

BvB93 commented Sep 1, 2023

Very much agreed yes. It's a small issue but one that can (and should) be easily fixed.
See #24611.

@pedro-w
Copy link
Author

pedro-w commented Sep 1, 2023

Thank you very much for fixing this. Is clip the only function affected though, might there be more?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants