Skip to content
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

FIX: remove ipython import warning from top-level shap import #3090

Merged
merged 4 commits into from Jul 13, 2023

Conversation

connortann
Copy link
Collaborator

@connortann connortann commented Jul 12, 2023

Fixes #3086

Removes the warning raised in _image.py if Ipython is not installed, and instead lazily raises an ImportError if the relevant function is called.

Also raises a more informative error in _text.py, where IPython's HTML and display functions may not be defined if not imported.

@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

Merging #3090 (c1622c7) into master (bf0adf8) will decrease coverage by 0.01%.
The diff coverage is 42.85%.

@@            Coverage Diff             @@
##           master    #3090      +/-   ##
==========================================
- Coverage   55.35%   55.35%   -0.01%     
==========================================
  Files          90       90              
  Lines       12873    12881       +8     
==========================================
+ Hits         7126     7130       +4     
- Misses       5747     5751       +4     
Impacted Files Coverage Δ
shap/__init__.py 68.33% <33.33%> (ø)
shap/plots/_text.py 54.45% <36.36%> (+0.04%) ⬆️
shap/plots/_image.py 73.04% <57.14%> (-1.07%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@connortann connortann changed the title Delay ipython warning until function called FIX: remove ipython import warning from top-level shap import Jul 12, 2023
@connortann connortann marked this pull request as ready for review July 13, 2023 08:30
shap/plots/_image.py Outdated Show resolved Hide resolved
@LukeHankey
Copy link

There is also a similar error message at shap/__init__.py:22 for matplotlib. Should this be changed from a ValueError to an ImportError?

@connortann
Copy link
Collaborator Author

I also propose changing the import warning in shap.__init__.py to a full ImportError. If the plotting functions are called and do not work, an explicit exception seems appropriate.

@LukeHankey
Copy link

I also propose changing the import warning in shap.__init__.py to a full ImportError. If the plotting functions are called and do not work, an explicit exception seems appropriate.

In that case, you won't need to import warnings in shap.__init__.py then

@connortann connortann merged commit a0219d0 into master Jul 13, 2023
13 of 15 checks passed
@connortann connortann deleted the fix/ipython-warning branch July 13, 2023 12:38
@connortann connortann added this to the 0.42.1 milestone Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IPython warning
2 participants