Skip to content

Commit

Permalink
Reducing testing time (#1625)
Browse files Browse the repository at this point in the history
* Marking slow tests

* Group torch tests

---------

Co-authored-by: Blazej Nowicki <blazej.nowicki@unit8.co>
  • Loading branch information
BlazejNowicki and BlazejNowickiU8 authored Mar 19, 2023
1 parent f7c292a commit 95f4d4f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions darts/tests/datasets/test_dataset_loaders.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

import pytest

from darts import TimeSeries
from darts.datasets import (
_DEFAULT_PATH,
Expand Down Expand Up @@ -128,6 +130,7 @@ def tearDown(self):
os.remove(os.path.join(default_directory, f))
os.rmdir(DatasetLoader._DEFAULT_DIRECTORY)

@pytest.mark.slow
def test_ok_dataset(self):
for width, dataset_cls in zip(width_datasets, datasets):
dataset = dataset_cls()
Expand Down
3 changes: 3 additions & 0 deletions darts/tests/models/forecasting/test_TCN.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from darts.logging import get_logger
from darts.metrics import mae
from darts.tests.base_test_class import DartsBaseTestClass
Expand Down Expand Up @@ -65,6 +67,7 @@ def test_performance(self):

self.assertTrue(mae(pred, test) < 0.3)

@pytest.mark.slow
def test_coverage(self):
torch.manual_seed(0)
input_chunk_lengths = range(20, 50)
Expand Down
2 changes: 2 additions & 0 deletions darts/tests/models/forecasting/test_historical_forecasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ def test_regression_auto_start_multiple_no_cov(self):
"of retrain=True and overlap_end=False, and a time index of type DateTimeIndex.",
)

@pytest.mark.slow
@unittest.skipUnless(
TORCH_AVAILABLE,
"Torch not available. auto start and multiple time series for torch models will be skipped.",
Expand Down Expand Up @@ -637,6 +638,7 @@ def test_regression_auto_start_multiple_with_cov(self):
" retrain=True and overlap_end=False",
)

@pytest.mark.slow
@unittest.skipUnless(
TORCH_AVAILABLE,
"Torch not available. auto start and multiple time series for torch models and covariates "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def test_forecast_time_index(self):
self.assertEqual(pred.start_time(), pd.Timestamp("20130121"))
self.assertEqual(pred.end_time(), pd.Timestamp("20130125"))

@pytest.mark.slow
def test_statsmodels_future_models(self):

# same tests, but VARIMA requires to work on a multivariate target series
Expand Down
3 changes: 3 additions & 0 deletions darts/tests/models/forecasting/test_probabilistic_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import pytest

from darts import TimeSeries
from darts.logging import get_logger
Expand Down Expand Up @@ -135,6 +136,7 @@
]


@pytest.mark.slow
class ProbabilisticTorchModelsTestCase(DartsBaseTestClass):
np.random.seed(0)

Expand All @@ -144,6 +146,7 @@ class ProbabilisticTorchModelsTestCase(DartsBaseTestClass):
constant_noisy_multivar_ts = constant_noisy_ts.stack(constant_noisy_ts)
num_samples = 5

@pytest.mark.slow
def test_fit_predict_determinism(self):

for model_cls, model_kwargs, _ in models_cls_kwargs_errs:
Expand Down
4 changes: 4 additions & 0 deletions darts/tests/models/forecasting/test_regression_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import numpy as np
import pandas as pd
import pytest
from sklearn.ensemble import HistGradientBoostingRegressor, RandomForestRegressor
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import OneHotEncoder
Expand Down Expand Up @@ -1191,6 +1192,7 @@ def test_models_runnability(self):
prediction = model_instance.predict(n=1)
self.assertEqual(len(prediction), 1)

@pytest.mark.slow
def test_fit(self):
multi_models_modes = [True, False]
for mode in multi_models_modes:
Expand Down Expand Up @@ -2217,6 +2219,7 @@ class ProbabilisticRegressionModelsTestCase(DartsBaseTestClass):
constant_noisy_multivar_ts = constant_noisy_ts.stack(constant_noisy_ts)
num_samples = 5

@pytest.mark.slow
def test_fit_predict_determinism(self):
multi_models_modes = [False, True]
for mode in multi_models_modes:
Expand All @@ -2237,6 +2240,7 @@ def test_fit_predict_determinism(self):
pred3 = model.predict(n=10, num_samples=2).values()
self.assertTrue((pred2 != pred3).any())

@pytest.mark.slow
def test_probabilistic_forecast_accuracy(self):
multi_models_modes = [True, False]
for mode in multi_models_modes:
Expand Down
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
addopts = --strict-markers
markers =
slow: marks tests as slow (deselect with '-m "not slow"')

0 comments on commit 95f4d4f

Please sign in to comment.