Skip to content

Commit

Permalink
Merge pull request #312 from understandable-machine-intelligence-lab/…
Browse files Browse the repository at this point in the history
…mprt-metrics

Mprt metrics
  • Loading branch information
annahedstroem authored Nov 24, 2023
2 parents 6d4efbb + 283f9ef commit 27eeb00
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions quantus/metrics/randomisation/smooth_mprt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# You should have received a copy of the GNU Lesser General Public License along with Quantus. If not, see <https://www.gnu.org/licenses/>.
# Quantus project URL: <https://github.com/understandable-machine-intelligence-lab/Quantus>.

import sys
import warnings
from typing import (
Any,
Expand Down Expand Up @@ -499,14 +498,15 @@ def evaluate_instance(

try:
return self.similarity_func(a_perturbed_flat, a_flat)
except stats._warnings_errors.ConstantInputWarning:
except Exception as e:
print(f"Encountered exception: {e} in similarity measure calculation")
warnings.warn(
"Encountered constant input in similarity measure calculation.",
"Setting similarity output to 1.",
UserWarning,
)
return 1.0

# Compute similarity measure.
# Compute similarity measure.
return self.similarity_func(a_perturbed_flat, a_flat)

def custom_preprocess(
Expand Down

0 comments on commit 27eeb00

Please sign in to comment.