Skip to content

Commit 2ba17ff

Browse files
committed
fix a few unittests
1 parent c0fa599 commit 2ba17ff

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

_doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from sphinx_runpython.github_link import make_linkcode_resolve
44
from sphinx_runpython.conf_helper import has_dvipng, has_dvisvgm
5-
from mlinsights import __version__, has_cuda
5+
from mlinsights import __version__
66

77
extensions = [
88
"sphinx.ext.autodoc",
@@ -50,7 +50,7 @@
5050

5151

5252
def setup(app):
53-
app.add_config_value("HAS_CUDA", "1" if has_cuda() else "0", "env")
53+
app.add_config_value("HAS_CUDA", "0")
5454

5555

5656
html_theme = "furo"

_doc/examples/plot_search_images_torch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070

7171
url = "https://github.com/sdpython/mlinsights/raw/ref/_doc/examples/data/dog-cat-pixabay.zip"
7272
files = unzip_files(url, where_to="simages/category")
73+
if len(files) == 0:
74+
raise FileNotFoundError(f"No images where unzipped from {url!r}.")
7375
len(files), files[0]
7476

7577
##########################################

_unittests/ut_search_rank/test_LONG_search_images_torch.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,20 @@ def test_search_predictions_torch(self):
2828
model = tmodels.squeezenet1_1(pretrained=True)
2929

3030
# images
31+
this = os.path.dirname(__file__)
3132
with tempfile.TemporaryDirectory() as temp:
32-
dest = os.path.join(temp, "simages")
33-
os.mkdir(dest)
34-
zipname = os.path.join(
35-
temp,
36-
"..",
33+
sub = os.path.join(temp, "simages")
34+
os.mkdir(sub)
35+
zipimg = os.path.join(
36+
this,
3737
"..",
3838
"..",
3939
"_doc",
40-
"notebooks",
41-
"explore",
40+
"examples",
4241
"data",
4342
"dog-cat-pixabay.zip",
4443
)
45-
files = unzip_files(zipname, where_to=dest)
44+
files = unzip_files(zipimg, where_to=sub)
4645
self.assertTrue(len(files) > 0)
4746

4847
# sequence of images

mlinsights/ext_test_case.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ def assertEqualFloat(self, a, b, precision=1e-5):
307307
except AssertionError:
308308
raise AssertionError(f"{a} != {b} (p={precision})")
309309

310+
def assertEndsWith(self, suffix: str, text: str):
311+
if not text.endswith(suffix):
312+
raise AssertionError(f"Unable to find {suffix!r} in {text!r}.")
313+
310314
@classmethod
311315
def tearDownClass(cls):
312316
for name, line, w in cls._warns:

mlinsights/helpers/pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,5 @@ def decision_function(self, X, *args, **kwargs):
210210
setattr(model, k, MethodType(new_methods[k], model))
211211
except AttributeError:
212212
warnings.warn(
213-
f"Unable to overwrite method {k!r} for class " f"{type(model)!r}."
213+
f"Unable to overwrite method {k!r} for class {type(model)!r}."
214214
)

0 commit comments

Comments
 (0)