Skip to content

Fix version check bug #940

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/utils/test_sample_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import torch
from captum._utils.sample_gradient import SampleGradientWrapper, SUPPORTED_MODULES
from packaging import version
from tests.helpers.basic import assertTensorAlmostEqual, BaseTest
from tests.helpers.basic_models import (
BasicModel_ConvNet_One_Conv,
Expand Down Expand Up @@ -37,7 +38,7 @@ def test_sample_grads_conv_mean_multi_inp(self) -> None:
self._compare_sample_grads_per_sample(model, inp, lambda x: torch.mean(x))

def test_sample_grads_modified_conv_mean(self) -> None:
if torch.__version__ < "1.8":
if version.parse(torch.__version__) < version.parse("1.8.0"):
raise unittest.SkipTest(
"Skipping sample gradient test with 3D linear module"
"since torch version < 1.8"
Expand All @@ -50,7 +51,7 @@ def test_sample_grads_modified_conv_mean(self) -> None:
)

def test_sample_grads_modified_conv_sum(self) -> None:
if torch.__version__ < "1.8":
if version.parse(torch.__version__) < version.parse("1.8.0"):
raise unittest.SkipTest(
"Skipping sample gradient test with 3D linear module"
"since torch version < 1.8"
Expand Down