-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added kwargs tests and code to raise warning for extra kwarg
- Loading branch information
cpranav93
committed
Jan 18, 2024
1 parent
79e2831
commit ce779fd
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from unittest import TestCase | ||
import pytest | ||
import dianna | ||
from tests.test_onnx_runner import generate_data | ||
import numpy as np | ||
|
||
class initialize_method(TestCase): | ||
|
||
def test_lime_image_correct_kwargs(self): | ||
model_filename = 'tests/test_data/mnist_model.onnx' | ||
input_data = generate_data(batch_size=1)[0].astype(np.float32) | ||
axis_labels = ('channels', 'y', 'x') | ||
labels = [1] | ||
|
||
dianna.explain_image(model_filename, | ||
input_data, | ||
method='LIME', | ||
labels=labels, | ||
kernel=None, | ||
kernel_width=25, | ||
verbose=False, | ||
feature_selection='auto', | ||
random_state=None, | ||
axis_labels=axis_labels, | ||
preprocess_function=None, | ||
top_labels=None, | ||
num_features=10, | ||
num_samples=5000, | ||
return_masks=True, | ||
positive_only=False, | ||
hide_rest=True, | ||
) | ||
|
||
def test_lime_image_extra_kwarg(self): | ||
model_filename = 'tests/test_data/mnist_model.onnx' | ||
input_data = generate_data(batch_size=1)[0].astype(np.float32) | ||
axis_labels = ('channels', 'y', 'x') | ||
labels = [1] | ||
|
||
with self.assertWarns(Warning): | ||
dianna.explain_image(model_filename, | ||
input_data, | ||
method='LIME', | ||
labels=labels, | ||
kernel=None, | ||
kernel_width=25, | ||
verbose=False, | ||
feature_selection='auto', | ||
random_state=None, | ||
axis_labels=axis_labels, | ||
preprocess_function=None, | ||
top_labels=None, | ||
num_features=10, | ||
num_samples=5000, | ||
return_masks=True, | ||
positive_only=False, | ||
hide_rest=True, | ||
extra_kwarg=None | ||
) | ||
|