Skip to content

Commit

Permalink
Only import cupy if the machine has GPUs available
Browse files Browse the repository at this point in the history
  • Loading branch information
smokestacklightnin committed Aug 9, 2023
1 parent 4be0cf6 commit db117eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion stardis/opacities/tests/test_voigt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
from math import sqrt
from numba import cuda
import cupy as cp

from stardis.opacities.voigt import (
faddeeva,
_faddeeva_cuda,
Expand All @@ -13,6 +13,9 @@
# Test cases must also take into account use of a GPU to run. If there is no GPU then the test cases will fail.
GPUs_available = cuda.is_available()

if GPUs_available:
import cupy as cp


@pytest.mark.parametrize(
"faddeeva_sample_values_input, faddeeva_sample_values_expected_result",
Expand Down
6 changes: 5 additions & 1 deletion stardis/opacities/voigt.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import numpy as np
import numba
from numba import cuda
import cupy as cp
import cmath

GPUs_available = cuda.is_available()

if GPUs_available:
import cupy as cp

SQRT_PI = np.sqrt(np.pi, dtype=float)


Expand Down

0 comments on commit db117eb

Please sign in to comment.