Skip to content

Commit e9f6330

Browse files
authored
Merge pull request #210 from ENSTA-U2IS-AI/dev
🐛 Fix unprotected optional dependency
2 parents 138af06 + 94af1d5 commit e9f6330

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Check that torch-uncertainty can be imported
7070
if: steps.changed-files-specific.outputs.only_changed != 'true'
7171
run: |
72-
python3 -c "import torch_uncertainty as tu"
72+
python3 -c "import torch_uncertainty; from torch_uncertainty.datamodules import MNISTDataModule"
7373
7474
- name: Install the optional dependencies
7575
if: steps.changed-files-specific.outputs.only_changed != 'true'

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
f"{datetime.now().year!s}, Adrien Lafage and Olivier Laurent"
2121
)
2222
author = "Adrien Lafage and Olivier Laurent"
23-
release = "0.7.0"
23+
release = "0.7.0.post1"
2424

2525
# -- General configuration ---------------------------------------------------
2626
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"
44

55
[project]
66
name = "torch_uncertainty"
7-
version = "0.7.0"
7+
version = "0.7.0.post1"
88
authors = [
99
{ name = "ENSTA U2IS AI", email = "[email protected]" },
1010
{ name = "Adrien Lafage", email = "[email protected]" },

torch_uncertainty/datasets/classification/ucr_uea.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import warnings
22
from collections.abc import Callable
3+
from importlib import util
34

45
import numpy as np
56
import torch
67
from einops import rearrange
78
from torch.utils.data import Dataset
8-
from tslearn.datasets import UCR_UEA_datasets
9+
10+
if util.find_spec("tslearn"):
11+
from tslearn.datasets import UCR_UEA_datasets
12+
13+
tslearn_installed = True
14+
else: # coverage: ignore
15+
tslearn_installed = False
916

1017

1118
class UCRUEADataset(Dataset):
@@ -32,6 +39,13 @@ def __init__(
3239
Raises:
3340
ValueError: If `split` is set to "ood" but `create_ood` is not set to True.
3441
"""
42+
if not tslearn_installed: # coverage: ignore
43+
raise ImportError(
44+
"The tslearn library is not installed. Please install "
45+
"torch_uncertainty with the timeseries option: "
46+
"""pip install -U "torch_uncertainty[timeseries]"."""
47+
)
48+
3549
if split == "ood" and not create_ood:
3650
raise ValueError(
3751
"Cannot use split 'ood' without setting create_ood to True. "

0 commit comments

Comments
 (0)