Revert "[MNT] remove unnecessary dependencies - numba" - #35
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reverts the earlier removal of numba by reintroducing it as a core dependency, restoring version reporting, and adding a pytest fixture to disable Numba JIT during anomaly model equality tests (to avoid PyOD/Numba failures under pytest).
Changes:
- Add
numbaback to core dependencies inpyproject.toml. - Add
numbato the dependency version report list (pycaret/utils/_show_versions.py). - Add a
disable_numbapytest fixture and apply it to the anomaly equality test (tests/test_models.py).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/test_models.py |
Adds a disable_numba fixture and uses it in the anomaly model equality test to avoid JIT-related failures. |
pyproject.toml |
Restores numba as an install-time dependency. |
pycaret/utils/_show_versions.py |
Adds numba to the dependency version reporting list. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+17
to
+22
| """ | ||
| Forces numba to use the original python functions. | ||
|
|
||
| This is required as numba code in pyod (anomaly) seems to not work | ||
| correctly leading to exceptions if ran from within pytest. | ||
| """ |
Comment on lines
+23
to
+35
| old = numba.config.DISABLE_JIT | ||
| # This will not affect already compiled functions... | ||
| numba.config.DISABLE_JIT = True | ||
|
|
||
| # ...which is why we force the Numba dispatcher to simply | ||
| # call the underlying python function for already compiled | ||
| # ones | ||
| def pyfunc_call(self, *args, **kwargs): | ||
| return self.py_func(*args, **kwargs) | ||
|
|
||
| with patch.object(Dispatcher, "__call__", pyfunc_call): | ||
| yield | ||
| numba.config.DISABLE_JIT = old |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #23 -
numbaseems coupled to tests as well as one specific estimator.This feels like bad design and too high coupling, but is outside the scope of the initial restoration work. Also see discussion in #30.