Unverified Commit c0bb6b06 authored by René Fritze's avatar René Fritze
Browse files

[tests.nn] properly guard tests for missing torch

parent 21533a13
Pipeline #146441 passed with stages
in 37 minutes and 56 seconds
......@@ -2,24 +2,13 @@
# Copyright pyMOR developers and contributors. All rights reserved.
# License: BSD 2-Clause License (https://opensource.org/licenses/BSD-2-Clause)
import os
import pytest
import numpy as np
def _skip_if_no_torch():
try:
import torch # NOQA
except ImportError as ie:
if not os.environ.get('DOCKER_PYMOR', False):
pytest.skip('skipped test due to missing Torch')
raise ie
from pymortests.base import skip_if_missing
@skip_if_missing('TORCH')
def test_linear_function_fitting():
_skip_if_no_torch()
from pymor.reductors.neural_network import multiple_restarts_training
from pymor.models.neural_network import FullyConnectedNN
......@@ -67,8 +56,8 @@ def test_linear_function_fitting():
assert all(loss < tol for loss in best_losses.values())
@skip_if_missing('TORCH')
def test_no_training_data():
_skip_if_no_torch()
from pymor.reductors.neural_network import multiple_restarts_training
from pymor.models.neural_network import FullyConnectedNN
......@@ -85,6 +74,7 @@ def test_no_training_data():
assert np.allclose(best_neural_network(torch.DoubleTensor(np.random.rand(n, d_in))).detach(), np.zeros(d_out))
@skip_if_missing('TORCH')
def test_issue_1649():
from pymor.models.neural_network import FullyConnectedNN
from pymor.models.neural_network import NeuralNetworkModel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment