qlib
qlib copied to clipboard
fix: migrate from gym to gymnasium for NumPy 2.0+ compatibility
- Replace gym dependency with gymnasium (maintained drop-in replacement)
- Update all gym imports to use gymnasium
- Add proper error handling for missing gymnasium dependency
- Add lazy loading of gymnasium in backtest module
- Fix hard crashes when using NumPy 2.0+
Fixes #2018
Description
Motivation and Context
How Has This Been Tested?
- [x] Pass the test by running:
pytest qlib/tests/test_all_pipeline.pyunder upper directory ofqlib. - [x] If you are adding a new feature, test on your own test scripts.
Screenshots of Test Results (if appropriate):
- Pipeline test:
- Your own tests:
Types of changes
- [x] Fix bugs
- [ ] Add new feature
- [ ] Update documentation
@microsoft-github-policy-service agree