Skip to content

ENH: Added display modes for show_runtime#26255

Open
ganesh-k13 wants to merge 14 commits intonumpy:mainfrom
ganesh-k13:show_runtime_modes
Open

ENH: Added display modes for show_runtime#26255
ganesh-k13 wants to merge 14 commits intonumpy:mainfrom
ganesh-k13:show_runtime_modes

Conversation

@ganesh-k13
Copy link
Copy Markdown
Member

@ganesh-k13 ganesh-k13 commented Apr 10, 2024

Changes

  • ENH: Added display modes for show_runtime

Allowed modes are same as show_config

`dicts` mode
In [2]: np.show_runtime(mode='dicts')
Out[2]:   
[{'numpy_version': '2.1.0.dev0+git20240410.6e3b392',
  'python': '3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]',
  'uname': {'machine': 'x86_64',
   'node': 'ganesh-MS-7B86',
   'processor': 'x86_64',
   'release': '5.15.0-100-generic',
   'system': 'Linux',
   'version': '#110-Ubuntu SMP Wed Feb 7 13:27:48 UTC 2024'}},
 {'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
   'found': ['SSSE3',
    'SSE41', 
    'POPCNT', 
    'SSE42',    
    'AVX',      
    'F16C',     
    'FMA3',     
    'AVX2'],    
   'not_found': ['AVX512F',
    'AVX512CD',    
    'AVX512_KNL',                                                                                
    'AVX512_KNM',       
    'AVX512_SKX',
    'AVX512_CLX',    
    'AVX512_CNL',          
    'AVX512_ICL']}},
 {'user_api': 'blas',
  'internal_api': 'openblas',
  'num_threads': 12,
  'prefix': 'libopenblas',
  'filepath': '/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so',
  'version': '0.3.20',
  'threading_layer': 'pthreads',
  'architecture': 'Zen'}]

`stdout` mode (default)
In [3]: np.show_runtime()
- numpy_version: 2.1.0.dev0+git20240410.6e3b392
  python: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
  uname:
    machine: x86_64
    node: ganesh-MS-7B86
    processor: x86_64
    release: 5.15.0-100-generic
    system: Linux
    version: '#110-Ubuntu SMP Wed Feb 7 13:27:48 UTC 2024'
- simd_extensions:
    baseline:
    - SSE
    - SSE2
    - SSE3
    found:
    - SSSE3
    - SSE41
    - POPCNT
    - SSE42
    - AVX
    - F16C
    - FMA3
    - AVX2
    not_found:
    - AVX512F
    - AVX512CD
    - AVX512_KNL
    - AVX512_KNM
    - AVX512_SKX
    - AVX512_CLX
    - AVX512_CNL
    - AVX512_ICL
- architecture: Zen
  filepath: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so
  internal_api: openblas
  num_threads: 12
  prefix: libopenblas
  threading_layer: pthreads
  user_api: blas
  version: 0.3.20

ToDo

  • Typing changes
  • Release notes

Notes

resolves: https://mail.python.org/archives/list/numpy-discussion@python.org/thread/NF7ET6O5ELCLXGEIN7P2AUO5S4MESMSK/

@ganesh-k13 ganesh-k13 requested a review from rgommers April 10, 2024 13:51
@ganesh-k13 ganesh-k13 self-assigned this Apr 10, 2024
ganesh-k13 added a commit to ganesh-k13/numpy that referenced this pull request Apr 10, 2024
ganesh-k13 added a commit to ganesh-k13/numpy that referenced this pull request Apr 10, 2024
ganesh-k13 added a commit to ganesh-k13/numpy that referenced this pull request Apr 10, 2024
@mattip
Copy link
Copy Markdown
Member

mattip commented Jul 3, 2024

@ganesh-k13 will you be continuing with this?

@ganesh-k13
Copy link
Copy Markdown
Member Author

@mattip , I'll pick it up this weekend. Got a bit busy lately.

@ganesh-k13 ganesh-k13 force-pushed the show_runtime_modes branch from 52f335a to 525373d Compare July 5, 2024 10:53
ganesh-k13 added a commit to ganesh-k13/numpy that referenced this pull request Jul 5, 2024
@ganesh-k13 ganesh-k13 marked this pull request as ready for review July 5, 2024 11:15
@mattip
Copy link
Copy Markdown
Member

mattip commented Jan 26, 2026

@ganesh-k13 it would be nice to push this over the finish line. There are merge conflicts.

@ganesh-k13
Copy link
Copy Markdown
Member Author

Thanks for looking into this. I'll get the merge conflicts resolved this week.

ganesh-k13 added a commit to ganesh-k13/numpy that referenced this pull request Jan 29, 2026
@ganesh-k13 ganesh-k13 force-pushed the show_runtime_modes branch 2 times, most recently from 180c3ea to 342e368 Compare January 29, 2026 05:40
@rgommers
Copy link
Copy Markdown
Member

mypy and stubtest have some complaints that look straightforward to resolve. Other that that, please do ask for re-review when ready.

@ganesh-k13
Copy link
Copy Markdown
Member Author

ganesh-k13 commented Jan 30, 2026

Debugging why basedpyright check is failing, I'm getting:

0.9995201535508638
Coverage 100.0% is below minimum required 100%

But it's quite hard to narrow down what is actually failing. Will fix this today.

[edit]

Made some tweaks and got the failing fns:

{'category': 'function', 'name': 'numpy.show_runtime', 'referenceCount': 1, 'isExported': True, 'isTypeKnown': False, 'isTypeAmbiguous': False, 'diagnostics': [{'file': '/Users/gakathir/Documents/os/numpy/build-install/usr/lib/python3.13/site-packages/numpy/lib/_utils_impl.pyi', 'severity': 'warning', 'message': 'No docstring found for function "numpy.show_runtime"', 'range': {'start': {'line': 586, 'character': 4}, 'end': {'line': 586, 'character': 16}}}, {'file': '/Users/gakathir/Documents/os/numpy/build-install/usr/lib/python3.13/site-packages/numpy/lib/_utils_impl.pyi', 'severity': 'error', 'message': 'Return type is partially unknown\n\xa0\xa0Return type is "dict[Unknown, Unknown] | None"\n\xa0\xa0\xa0\xa0Type argument 1 for class "dict" has unknown type\n\xa0\xa0\xa0\xa0Type argument 2 for class "dict" has unknown type', 'range': {'start': {'line': 586, 'character': 4}, 'end': {'line': 586, 'character': 16}}}]}
{'category': 'function', 'name': 'numpy.matlib.show_runtime', 'referenceCount': 1, 'isExported': True, 'isTypeKnown': False, 'isTypeAmbiguous': False, 'diagnostics': [{'file': '/Users/gakathir/Documents/os/numpy/build-install/usr/lib/python3.13/site-packages/numpy/__init__.pyi', 'severity': 'warning', 'message': 'No docstring found for function "numpy.matlib.show_runtime"', 'range': {'start': {'line': 416, 'character': 4}, 'end': {'line': 416, 'character': 16}}}, {'file': '/Users/gakathir/Documents/os/numpy/build-install/usr/lib/python3.13/site-packages/numpy/__init__.pyi', 'severity': 'error', 'message': 'Return type is partially unknown\n\xa0\xa0Return type is "dict[Unknown, Unknown] | None"\n\xa0\xa0\xa0\xa0Type argument 1 for class "dict" has unknown type\n\xa0\xa0\xa0\xa0Type argument 2 for class "dict" has unknown type', 'range': {'start': {'line': 416, 'character': 4}, 'end': {'line': 416, 'character': 16}}}]}

@ganesh-k13
Copy link
Copy Markdown
Member Author

I used Claude for 5a039dd, please do have a look as I'm not sure if it's optimal and can be somehow combined into one line. I think @jorenham might know?

Copy link
Copy Markdown
Member

@jorenham jorenham left a comment

Choose a reason for hiding this comment

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

The static typing changes are good now :)

# for optional f2py encoding detection
charset-normalizer
tzdata
types-PyYAML No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add a skip instead? I don't really like adding a new niche entry to the main test requirements file for a very minor gain.

If there's a desire to have this, we should factor out static typing dependencies.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need it to appease stubtest:

error: not checking stubs due to mypy build errors:
numpy/_utils/_config_helpers.py:25: error: Library stubs not installed for "yaml"  [import-untyped]
numpy/_utils/_config_helpers.py:25: note: Hint: "python3 -m pip install types-PyYAML"
numpy/_utils/_config_helpers.py:25: note: (or run "mypy --install-types" to install all missing stub packages)
numpy/_utils/_config_helpers.py:25: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

https://github.com/numpy/numpy/actions/runs/21467362112/job/61832206477?pr=26255

But either way, separating the test deps from the static typing dependencies sounds like a good idea to me. We used to only have mypy, but now we also need these typeshed stubs, and the upcoming pyrefly support will add also add pyrefly to that list.

Copy link
Copy Markdown
Member Author

@ganesh-k13 ganesh-k13 Feb 2, 2026

Choose a reason for hiding this comment

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

I have moved it to a new file: 22000a7 51a1c31, might have missed something in the CI, will wait for it to pass

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

CI is passing, no regressions on the requirements.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The types-PyYAML addition is still present here, can you remove it from this file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh my bad, I missed committing the file. I have removed mypy as well. Will wait for CI to complete.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The CI has started to fail, I'll fix them today.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All checks are passing now.

@ganesh-k13 ganesh-k13 force-pushed the show_runtime_modes branch 2 times, most recently from 7d01ec7 to 6259fd1 Compare February 10, 2026 08:32
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.

4 participants