-
Notifications
You must be signed in to change notification settings - Fork 13
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
added kwargs tests and code to raise warning for extra kwarg #693
Conversation
#693 resolves this issue. It is still in a draft stage but the idea is as follows:
Whether a warning or an error should be passed is to be decided based on whether additional kwargs get passed out of DIANNA to external functions like lime/shap. |
Update: I have now implemented the warnings for each method type and written tests for the same (except tests for tabular). This PR is ready for review |
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.
@cpranav93 thanks for the fixes. The implementation works fine. However, I found that there is a function get_kwargs_applicable_to_function. I think the warning should be implemented in this function in misc
script rather than individual warnings in each method in init
script. Here is a suggestion for that function:
function_kwargs = {
key: value
for key, value in kwargs.items()
if key in inspect.getfullargspec(function).args
}
# check if function is a bound method
if hasattr(function, '__self__'):
not_applicable = kwargs.copy()
for key in function_kwargs:
not_applicable.pop(key)
if not_applicable:
msg = f'Please note the following kwargs are not being used: {not_applicable}'
warnings.warn(msg)
The test_kwargs
that you implemented still works with this suggestion. I might miss some points regarding the development. If so, please let me know 😊
@SarahAlidoost, thanks for the review. Regarding your last point, the issue is that the kwargs are being used by two different functions so the warning should only be raised after the second function's kwargs are also popped. If implemented in the "get_kwargs_applicable_to_function" function, then it would check it after every function and not after both have been called. Alternatively, we could pop the kwargs and return the reduced list from the misc function and only raise the warning in the individual methods. Does that sound like a better alternative? I am open to suggestions. |
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.
@cpranav93 thanks for addressing the comments and explanations. I see the point regarding kwargs. Considering the current implementations of the modules, I agree that your fixes work fine. I approved this PR.
No description provided.