Skip to content

Commit

Permalink
Mark test relying on optional dependencies as skip
Browse files Browse the repository at this point in the history
  • Loading branch information
mschmidt87 committed May 25, 2020
1 parent 6cb69c9 commit f6c238c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/test_individual.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import math
import pickle
import pytest
import torch

try:
import sympy # noqa: F401

sympy_available = True
except ModuleNotFoundError:
sympy_available = False
try:
import torch # noqa: F401

torch_available = True
except ModuleNotFoundError:
torch_available = False

import gp
from gp.individual import Individual
Expand Down Expand Up @@ -56,6 +68,7 @@ def test_individual_with_parameter_python():
assert y[0] == pytest.approx(x[0] + c)


@pytest.mark.skipif(not torch_available, reason="torch is not installed.")
def test_individual_with_parameter_torch():

primitives = (gp.Add, gp.Parameter)
Expand Down Expand Up @@ -96,6 +109,7 @@ def test_individual_with_parameter_torch():
assert y[1, 0].item() == pytest.approx(x[1, 0].item() + c)


@pytest.mark.skipif(not sympy_available, reason="sympy is not installed.")
def test_individual_with_parameter_sympy():

primitives = (gp.Add, gp.Parameter)
Expand Down Expand Up @@ -134,6 +148,7 @@ def test_individual_with_parameter_sympy():
assert y == pytest.approx(x[0] + c)


@pytest.mark.skipif(not torch_available, reason="torch is not installed.")
def test_to_and_from_torch_plus_backprop():
primitives = (gp.Mul, gp.Parameter)
genome = gp.Genome(1, 1, 2, 2, 1, primitives)
Expand Down

0 comments on commit f6c238c

Please sign in to comment.