- 
                Notifications
    
You must be signed in to change notification settings  - Fork 423
 
          [Test] Removed numpy.compact in numpy>=2.0.0
          #1672
        
          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
Conversation
0a07aad    to
    aede826      
    Compare
  
    numpy.compact fails the pytest
      numpy.compact fails the pytestnumpy.compact fails pytest
      numpy.compact fails pytestnumpy.compact fails pytest
      | 
           When running  ======================================================== short test summary info =========================================================
FAILED tests/test_config/test_config.py::TestConfig::test_dump - RuntimeError
FAILED tests/test_config/test_config.py::TestConfig::test_deepcopy - RuntimeError
FAILED tests/test_config/test_config.py::TestConfig::test_copy - RuntimeError
FAILED tests/test_config/test_config.py::TestConfig::test_lazy_import - RuntimeError
FAILED tests/test_config/test_lazy.py::TestImportTransformer::test_lazy_module - ModuleNotFoundError: Failed to import numpy in None, line 5 for No module named 'numpy.compat'
FAILED tests/test_fileio/test_fileclient.py::TestFileClient::test_http_backend[http-None] - urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
FAILED tests/test_fileio/test_fileclient.py::TestFileClient::test_http_backend[None-http] - urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
FAILED tests/test_hooks/test_sync_buffers_hook.py::TestSyncBuffersHook::test_sync_buffers_hook - RuntimeError: Process 1 exited with error code 10 and exception:
FAILED tests/test_hooks/test_sync_buffers_hook.py::TestSyncBuffersHook::test_with_runner - RuntimeError: Process 1 exited with error code 10 and exception:
FAILED tests/test_logging/test_message_hub.py::TestMessageHub::test_get_scalars - Failed: DID NOT RAISE <class 'AssertionError'>
FAILED tests/test_model/test_model_utils.py::test_convert_syncbn - ValueError: Default process group has not been initialized, please make sure to call init_process_group.
FAILED tests/test_optim/test_optimizer/test_optimizer.py::TestBuilder::test_build_optimizer - AttributeError: 'str' object has no attribute 'update'
FAILED tests/test_optim/test_optimizer/test_optimizer_wrapper.py::TestAmpOptimWrapper::test_init - AssertionError: <torch.amp.grad_scaler.GradScaler object at 0x7f96d4eb6570> is not an instance of <class 'torch.cuda.amp.grad_scaler....
FAILED tests/test_runner/test_runner.py::TestRunner::test_build_optim_wrapper - AttributeError: 'str' object has no attribute 'update'
FAILED tests/test_runner/test_runner.py::TestRunner::test_checkpoint - AttributeError: 'str' object has no attribute 'update'
FAILED tests/test_runner/test_runner.py::TestRunner::test_train - AttributeError: 'str' object has no attribute 'update'
FAILED tests/test_strategies/test_fsdp.py::TestStrategy::test_run_strategy - torch.multiprocessing.spawn.ProcessRaisedException: 
FAILED tests/test_utils/test_package_utils.py::test_get_install_path - importlib.metadata.PackageNotFoundError: No package metadata was found for unknown
FAILED tests/test_utils/test_timer.py::test_timer_run - assert 0.03835725784301758 < 0.03
FAILED tests/test_utils/test_timer.py::test_timer_context - AssertionError: assert 'time: 1.1s\n' == 'time: 1.0s\n'
FAILED tests/test_visualizer/test_vis_backend.py::TestAimVisBackend::test_experiment - ImportError: Please run "pip install aim" to install aim
FAILED tests/test_visualizer/test_vis_backend.py::TestAimVisBackend::test_add_config - ImportError: Please run "pip install aim" to install aim
FAILED tests/test_visualizer/test_vis_backend.py::TestAimVisBackend::test_add_image - ImportError: Please run "pip install aim" to install aim
FAILED tests/test_visualizer/test_vis_backend.py::TestAimVisBackend::test_add_scalar - ImportError: Please run "pip install aim" to install aim
FAILED tests/test_visualizer/test_vis_backend.py::TestAimVisBackend::test_add_scalars - ImportError: Please run "pip install aim" to install aim
FAILED tests/test_visualizer/test_vis_backend.py::TestAimVisBackend::test_close - ImportError: Please run "pip install aim" to install aim
================================= 26 failed, 907 passed, 89 skipped, 2994 warnings in 628.08s (0:10:28) ==================================I'm trying to fix these errors.  | 
    
… lazy import test.
| 
           Now  python3 -m pytest tests/test_config/test_lazy.py -v
=================================================== test session starts ===================================================
platform linux -- Python 3.13.9, pytest-8.4.1, pluggy-1.6.0 -- /home/mgam/miniforge3/envs/pt/bin/python3
cachedir: .pytest_cache
rootdir: /home/mgam/mgam_repos/mmengine
configfile: pytest.ini
plugins: anyio-4.9.0, hydra-core-1.3.2
collected 4 items                                                                                                         
tests/test_config/test_lazy.py::TestImportTransformer::test_lazy_module PASSED                                      [ 25%]
tests/test_config/test_lazy.py::TestLazyObject::test_build PASSED                                                   [ 50%]
tests/test_config/test_lazy.py::TestLazyObject::test_init PASSED                                                    [ 75%]
tests/test_config/test_lazy.py::TestLazyAttr::test_build PASSED                                                     [100%]
==================================================== 4 passed in 0.15s ==================================================== | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes pytest failures caused by the deprecated numpy.compat module by replacing it with numpy.fft in test files. NumPy 2.0 removed the compat module as Python 2 is no longer supported.
Key Changes:
- Replaced 
numpy.compatimports withnumpy.fftin test files - Updated test assertions and variable names to reference 
fftinstead ofcompat - Updated code comments to reflect the module name change
 
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description | 
|---|---|
| tests/test_config/test_lazy.py | Replaced all references to numpy.compat with numpy.fft in imports, assertions, and variable names | 
| tests/data/config/lazy_module_config/test_ast_transform.py | Updated import statement from numpy.compat to numpy.fft | 
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 
           @HAOCHENYE This one is ready to be reviewed.  | 
    
numpy.compact fails pytestnumpy.compact in numpy>=2.0.0
      
Motivation
This PR is a sub-PR of #1665.
According to https://numpy.org/devdocs/release/2.0.0-notes.html#deprecations,
np.compathas been deprecated, as Python 2 is no longer supported.This causes several failures in pytest:
tests/test_config/test_lazy.py. Fixing this issue now.Modification
test_lazy.pyutilizenumpy.compatas an example numpy module to test if the lazy import function can properly working. So simply replacing it with any other existing numpy module,numpy.fftfor this PR.