Skip to content

Commit 90f102c

Browse files
committed
Merge remote-tracking branch 'origin/main' into test_against_nightly_deps
# Conflicts: # setup.py
2 parents defc04d + 19e8ab8 commit 90f102c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1259
-1424
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ docs/_build/
112112
docs/auto_examples/
113113
docs/examples/misc/ks_trained.hdf5
114114
docs/gen_modules/*/
115+
docs/**/sg_execution_times.rst
115116

116117
# Local files
117118
private_info.md

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Changelogs for this project are recorded in this file since v0.2.0.
1515

1616
* Explicit exception when using Global Alignment Kernel with sigma close to zero ([#440](https://github.com/tslearn-team/tslearn/issues/440))
1717
* Fix shifting in K-shape shape extraction process ([#385](https://github.com/tslearn-team/tslearn/issues/385))
18+
* Support for `scikit-learn` up to 1.7 ([#549](https://github.com/tslearn-team/tslearn/issues/549))
1819

1920
### Removed
2021

MANIFEST.in

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
include *.rst
2-
recursive-include tslearn *.c *.h *.pyx
3-
include LICENSE
4-
include README.md
5-
include pyproject.toml
61
include conftest.py
7-
include MANIFEST.in
82

93
# exclude from sdist
104
recursive-exclude .github *
5+
recursive-exclude tslearn.egg-info *
116
exclude .readthedocs.yml
127
exclude azure-pipelines.yml
8+
exclude sonar-project.properties
9+
exclude .gitignore

azure-pipelines.yml

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
set -xe
4444
python -m pip install pytest-azurepipelines
4545
pip list
46-
python -m pytest -v tslearn/ -k "not test_all_estimators"
46+
python -m pytest -v -k "not test_all_estimators"
4747
displayName: 'Test'
4848
4949
- job: 'doctests_linux'
@@ -81,7 +81,7 @@ jobs:
8181
set -xe
8282
python -m pip install pytest-azurepipelines
8383
pip list
84-
python -m pytest -v tslearn/ --doctest-modules -k "not test_ or test_all_estimators"
84+
python -m pytest -v --doctest-modules -k "not test_ or test_all_estimators"
8585
displayName: 'Doctest'
8686
8787
- job: 'tests_macOS'
@@ -119,7 +119,7 @@ jobs:
119119
set -xe
120120
python -m pip install pytest-azurepipelines
121121
pip list
122-
python -m pytest -v tslearn/ -k "not test_all_estimators"
122+
python -m pytest -v -k "not test_all_estimators"
123123
displayName: 'Test'
124124
125125
- job: 'doctests_macOS'
@@ -157,7 +157,7 @@ jobs:
157157
set -xe
158158
python -m pip install pytest-azurepipelines
159159
pip list
160-
python -m pytest -v tslearn/ --doctest-modules -k "not test_ or test_all_estimators"
160+
python -m pytest -v --doctest-modules -k "not test_ or test_all_estimators"
161161
displayName: 'Doctest'
162162
163163
- job: 'tests_windows'
@@ -192,7 +192,7 @@ jobs:
192192
- script: |
193193
python -m pip install pytest-azurepipelines
194194
pip list
195-
python -m pytest -v tslearn/ -k "not test_all_estimators"
195+
python -m pytest -v -k "not test_all_estimators"
196196
displayName: 'Test'
197197
198198
- job: 'doctests_windows'
@@ -227,16 +227,12 @@ jobs:
227227
- script: |
228228
python -m pip install pytest-azurepipelines
229229
pip list
230-
python -m pytest -v tslearn/ --doctest-modules -k "not test_ or test_all_estimators"
230+
python -m pytest -v --doctest-modules -k "not test_ or test_all_estimators"
231231
displayName: 'Doctest'
232232
233-
- job: 'tests_basic'
233+
- job: 'tests_doctests_basic'
234234
pool:
235235
vmImage: 'ubuntu-latest'
236-
strategy:
237-
matrix:
238-
Python310:
239-
python.version: '3.10'
240236
variables:
241237
OMP_NUM_THREADS: '2'
242238
NUMBA_NUM_THREADS: '2'
@@ -245,8 +241,8 @@ jobs:
245241
steps:
246242
- task: UsePythonVersion@0
247243
inputs:
248-
versionSpec: '$(python.version)'
249-
displayName: 'Use Python $(python.version)'
244+
versionSpec: '3.10'
245+
displayName: 'Use Python 3.10'
250246

251247
- script: |
252248
set -xe
@@ -259,16 +255,20 @@ jobs:
259255
set -xe
260256
python -m pip install pytest-azurepipelines
261257
pip list
262-
python -m pytest -v tslearn/ -k "not test_all_estimators"
258+
python -m pytest -v --doctest-modules
263259
displayName: 'Test'
264260
265-
- job: 'doctests_basic'
261+
- job: 'tests_sklearn_version'
266262
pool:
267263
vmImage: 'ubuntu-latest'
268264
strategy:
269265
matrix:
270-
Python310:
271-
python.version: '3.10'
266+
sklearn1_4:
267+
skLearnVersion: '1.4.0'
268+
sklearn1_5:
269+
skLearnVersion: '1.5.0'
270+
sklearn1_6:
271+
skLearnVersion: '1.6.0'
272272
variables:
273273
OMP_NUM_THREADS: '2'
274274
NUMBA_NUM_THREADS: '2'
@@ -277,30 +277,28 @@ jobs:
277277
steps:
278278
- task: UsePythonVersion@0
279279
inputs:
280-
versionSpec: '$(python.version)'
281-
displayName: 'Use Python $(python.version)'
280+
versionSpec: '3.11'
281+
displayName: 'Use Python 3.11'
282282

283283
- script: |
284284
set -xe
285285
python --version
286286
python -m pip install --upgrade pip
287-
python -m pip install .[tests]
288-
displayName: 'Install tslearn and dependencies for tests'
287+
python -m pip install 'scikit-learn~=$(skLearnVersion)'
288+
python -m pip install .[tests,all_features]
289+
displayName: 'Install tslearn all_features and dependencies for tests'
289290
290291
- script: |
291292
set -xe
292293
python -m pip install pytest-azurepipelines
293294
pip list
294-
python -m pytest -v tslearn/ --doctest-modules -k 'not test_ or test_all_estimators'
295-
displayName: 'Doctest'
295+
python -m pytest -v
296+
displayName: 'Test sklearn versions'
297+
296298
297299
- job: 'codecov' # must be a separate job to only disable Numbas's JIT here
298300
pool:
299301
vmImage: 'ubuntu-latest'
300-
strategy:
301-
matrix:
302-
Python310:
303-
python.version: '3.10'
304302
variables:
305303
OMP_NUM_THREADS: '2'
306304
NUMBA_DISABLE_JIT: '1'
@@ -310,22 +308,28 @@ jobs:
310308
steps:
311309
- task: UsePythonVersion@0
312310
inputs:
313-
versionSpec: '$(python.version)'
314-
displayName: 'Use Python $(python.version)'
311+
versionSpec: '3.11'
312+
displayName: 'Use Python 3.11'
315313

316314
- script: |
317315
set -xe
318316
python --version
319317
python -m pip install --upgrade pip
320-
python -m pip install .[tests,all_features]
318+
python -m pip install .[tests]
321319
displayName: 'Install tslearn all_features and dependencies for tests'
322320
323321
- script: |
324322
set -xe
325323
python -m pip install pytest-azurepipelines
326324
python -m pip install coverage pytest-cov
327325
pip list
328-
python -m pytest -v tslearn/ --cov=tslearn
326+
python -m pytest -v --cov=tests --cov=tslearn
327+
python -m pip install .[all_features]
328+
pip list
329+
python -m pytest -v --cov=tests --cov=tslearn --cov-append
330+
pip install scikit-learn~=1.4.0
331+
pip list
332+
python -m pytest -v --cov=tests --cov=tslearn --cov-append -k "test_all_estimators or test_scaler_allow_variable_length"
329333
displayName: 'Test'
330334
331335
# Upload coverage to codecov.io

docs/conf.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
import os
1616
import subprocess
1717
import sys
18+
import tomllib
1819
import warnings
1920

21+
from packaging.requirements import Requirement
22+
2023
# If extensions (or modules to document with autodoc) are in another directory,
2124
# add these directories to sys.path here. If the directory is relative to the
2225
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -242,15 +245,16 @@ def find_source():
242245

243246
def get_dependencies():
244247
""" Retrieve required dependencies """
245-
import distutils.core
246-
from packaging.requirements import Requirement
247-
setup_ = distutils.core.run_setup("../setup.py", stop_after='run')
248-
return [Requirement(requirement) for requirement in setup_.install_requires]
248+
with open("../pyproject.toml", "rb") as f:
249+
pyproject = tomllib.load(f)
250+
return [Requirement(requirement) for requirement in pyproject["project"]["dependencies"]]
251+
249252

250253
rst_templates= {
251254
"dependencies.rst": {"dependencies": get_dependencies()}
252255
}
253256

257+
254258
def setup(app):
255259
""" Setup our app """
256260
# Ensure pandoc is installed

docs/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Here is a description of useful tools to check your code locally:
117117
`pytest <https://docs.pytest.org/en/latest/>`_ and `pytest-cov <https://pytest-cov.readthedocs.io/en/latest/>`_ Python packages::
118118

119119
$ pip install -e .[tests,all_features]
120-
$ pytest --cov tslearn
120+
$ pytest --cov
121121

122122
- To build the documentation locally, install the following packages and run
123123
the ``make html`` command in the ``tslearn/docs`` folder::

docs/examples/autodiff/plot_soft_dtw_loss_for_pytorch_nn.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ def fit(self, X, y, max_epochs=10):
115115
ts_index = 50
116116
y_pred = model(X_test[:, :150, 0]).detach().numpy()
117117

118-
plt.figure()
118+
plt.figure(1, layout="constrained")
119119
plt.title('Multi-step ahead forecasting using MSE')
120120
plt.plot(X_test[ts_index].ravel())
121121
plt.plot(np.arange(150, 275), y_pred[ts_index], 'r-')
122-
122+
plt.show()
123123

124124
##############################################################################
125125
# Using Soft-DTW as a loss function
@@ -143,7 +143,8 @@ def fit(self, X, y, max_epochs=10):
143143

144144
y_pred = model(X_test[:, :150, 0]).detach().numpy()
145145

146-
plt.figure()
146+
plt.figure(2, layout="constrained")
147147
plt.title('Multi-step ahead forecasting using Soft-DTW loss')
148148
plt.plot(X_test[ts_index].ravel())
149149
plt.plot(np.arange(150, 275), y_pred[ts_index], 'r-')
150+
plt.show()

docs/examples/metrics/plot_dtw.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
path, sim = metrics.dtw_path(s_y1, s_y2)
6969

70-
plt.figure(1, figsize=(8, 8))
70+
plt.figure(layout="constrained", figsize=(8, 8))
7171

7272
# definitions for the axes
7373
left, bottom = 0.01, 0.1
@@ -100,5 +100,4 @@
100100
ax_s_y.axis("off")
101101
ax_s_y.set_ylim((0, sz - 1))
102102

103-
plt.tight_layout()
104103
plt.show()

docs/examples/metrics/plot_dtw_custom_metric.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def arc_length(angle_1, angle_2, r=1.):
103103
rect_s_x = [left_h, bottom_h, width, h_ts]
104104

105105
# Plot example 1
106-
plt.figure(1, figsize=(6, 6))
106+
plt.figure(1, layout="constrained", figsize=(6, 6))
107107
ax_dist = plt.axes(rect_dist)
108108
ax_s_x = plt.axes(rect_s_x)
109109
ax_s_y = plt.axes(rect_s_y)
@@ -133,7 +133,7 @@ def arc_length(angle_1, angle_2, r=1.):
133133
horizontalalignment="center", verticalalignment="top")
134134

135135
# Plot example 2
136-
plt.figure(2, figsize=(6, 6))
136+
plt.figure(2, layout="constrained", figsize=(6, 6))
137137
ax_dist = plt.axes(rect_dist)
138138
ax_s_x = plt.axes(rect_s_x)
139139
ax_s_y = plt.axes(rect_s_y)
@@ -153,5 +153,4 @@ def arc_length(angle_1, angle_2, r=1.):
153153
ax_s_y.imshow(np.flip(dataset_2[0], axis=1), aspect="auto", cmap=cm)
154154
ax_s_y.axis("off")
155155

156-
plt.tight_layout()
157156
plt.show()

docs/examples/metrics/plot_lcss.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,4 @@
6262
plt.legend()
6363
plt.title("Time series matching with DTW")
6464

65-
plt.tight_layout()
6665
plt.show()

0 commit comments

Comments
 (0)