Skip to content

AttributeError: module 'numpy' has no attribute 'float'. #4729

@lutzroeder

Description

@lutzroeder

Bug Report

Describe the bug

AttributeError when using ONNX with latest NumPy 1.24.1

System information

  • ONNX version (e.g. 1.7): 1.13.0
  • Python version: 3.10.9
  • NumPy version: 1.24.1

Reproduction instructions

~: pip install numpy 
Successfully installed numpy-1.24.1
~: python
Python 3.10.9 (main, Dec 15 2022, 17:11:09) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
>>> import onnx.backend.test.case
>>> onnx.__version__
'1.13.0'
>>> onnx.backend.test.case.collect_snippets()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.10/site-packages/onnx/backend/test/case/__init__.py", line 11, in collect_snippets
    import_recursive(sys.modules[__name__])
  File "/opt/homebrew/lib/python3.10/site-packages/onnx/backend/test/case/utils.py", line 36, in import_recursive
    import_recursive(module)
  File "/opt/homebrew/lib/python3.10/site-packages/onnx/backend/test/case/utils.py", line 34, in import_recursive
    module = importlib.import_module(module_name)
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/homebrew/lib/python3.10/site-packages/onnx/backend/test/case/node/bernoulli.py", line 19, in <module>
    class Bernoulli(Base):
  File "/opt/homebrew/lib/python3.10/site-packages/onnx/backend/test/case/base.py", line 39, in __init__
    export()
  File "/opt/homebrew/lib/python3.10/site-packages/onnx/backend/test/case/node/bernoulli.py", line 28, in export_bernoulli_without_dtype
    x = np.random.uniform(0.0, 1.0, 10).astype(np.float)
  File "/opt/homebrew/lib/python3.10/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'. Did you mean: 'cfloat'?

@askhade @gramalingam @hwangdeyu

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions