Skip to content

Commit

Permalink
[MRG] Fix import error when torch is not installed. (#463)
Browse files Browse the repository at this point in the history
Co-authored-by: Yann Cabanes <[email protected]>
Co-authored-by: Romain Tavenard <[email protected]>
  • Loading branch information
3 people authored Jul 5, 2023
1 parent 9be9c7d commit 38cbe2c
Show file tree
Hide file tree
Showing 8 changed files with 314 additions and 261 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ and this project adheres to

Changelogs for this project are recorded in this file since v0.2.0.

## [Towards v0.6]


## [Towards v0.6.2]

## [v0.6.1]

### Fixed

* Fixed an import error when `torch` is not installed. This error appeared in tslearn v0.6.
`PyTorch` is now an optional dependency.

## [v0.6.0]

### Added

Expand Down
41 changes: 41 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,43 @@ jobs:
python.version: '3.8'
Python39:
python.version: '3.9'
variables:
OMP_NUM_THREADS: '2'
NUMBA_NUM_THREADS: '2'
PIP_PREFER_BINARY: 'true'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'

- script: |
set -xe
python --version
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install torch
displayName: 'Install dependencies'
- script: |
set -xe
python -m pip install -e .
displayName: 'Install tslearn'
- script: |
set -xe
python -m pip install pytest pytest-azurepipelines
python -m pip install scikit-learn==1.0
python -m pip install tensorflow==2.9.0
python -m pytest -v tslearn/ --doctest-modules
displayName: 'Test'
- job: 'linux_without_torch'
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
Python310:
python.version: '3.10'
variables:
Expand All @@ -32,6 +69,7 @@ jobs:
python --version
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip uninstall torch
displayName: 'Install dependencies'
- script: |
Expand Down Expand Up @@ -72,6 +110,7 @@ jobs:
python --version
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install torch
displayName: 'Install dependencies'
- script: |
Expand Down Expand Up @@ -124,6 +163,7 @@ jobs:
export OPENBLAS=$(brew --prefix openblas)
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install torch
displayName: 'Install dependencies'
- script: |
Expand Down Expand Up @@ -169,6 +209,7 @@ jobs:
python --version
python -m pip install --upgrade pip
python -m pip install -r requirements_nocast.txt
python -m pip install torch
displayName: 'Install dependencies'
- script: |
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ scipy
scikit-learn
joblib>=0.12
tensorflow>=2
torch
pandas
cesium
h5py
1 change: 0 additions & 1 deletion requirements_nocast.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ scipy
scikit-learn
joblib>=0.12
tensorflow>=2
torch
h5py
4 changes: 0 additions & 4 deletions tslearn/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
"""

from .backend import Backend, instantiate_backend, select_backend
from .numpy_backend import NumPyBackend
from .pytorch_backend import PyTorchBackend

__all__ = [
"Backend",
"instantiate_backend",
"select_backend",
"NumPyBackend",
"PyTorchBackend",
]
Loading

0 comments on commit 38cbe2c

Please sign in to comment.