-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Refactoring Exceptions #2580
Refactoring Exceptions #2580
Conversation
Thanks @alexisdrakopoulos, I like the idea! I agree that handling exceptions via string matching is not ideal, and there is clear room to improvement here. What you have looks like the right direction, so go for it. Once you have a PR ready I expect it will be a simple merge. |
There are three tests for which I need to update the exception catching. |
…os/shap into feat/refactor_exceptions
@slundberg can we try running tests? |
Codecov Report
@@ Coverage Diff @@
## master #2580 +/- ##
==========================================
+ Coverage 51.51% 51.60% +0.09%
==========================================
Files 90 91 +1
Lines 13116 13145 +29
==========================================
+ Hits 6757 6784 +27
- Misses 6359 6361 +2
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Just looked it over and it all looks good to me, except for one line I commented on. After you get a chance to look at that I think this is ready to merge. Thanks! |
…os/shap into feat/refactor_exceptions
SHAP currently calls Exception a lot throughout the code base. This makes it tough to handle exceptions internally as one has to match to messages to infer why an exception was raised.
For example; I want to try to build an explainer object and raise an error in cases where a tree explainer (or similar) won't work:
Since I want to avoid catching all the other Exceptions that might be raised I have to match against the message. This is brittle and ugly in my opinion, I would much rather have something like:
I am opening this draft PR which replaces some Exception calls with "more" appropriate ones including custom ones. As to not waste time in case this is not desired I wrote this very quickly and hence I'm sure some exceptions aren't the ideal ones to raise.
What do we think of doing it this way? If there's a positive reception to the idea I'll do it properly and open this as a PR.