Skip to content

Commit

Permalink
global coverage config, scipy fences back
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp committed Sep 25, 2024
1 parent 678bc6c commit bfd9e10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion glass/core/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np

if TYPE_CHECKING:
from numpy.typing import ArrayLike # pragma: no cover
from numpy.typing import ArrayLike


def nnls(
Expand Down
12 changes: 11 additions & 1 deletion tests/core/test_algorithm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import pytest

# check if scipy is available for testing
try:
import scipy
except ImportError:
HAVE_SCIPY = False
else:
del scipy
HAVE_SCIPY = True


@pytest.mark.skipif(not HAVE_SCIPY, reason="test requires SciPy")
def test_nnls(rng):
import numpy as np
from scipy.optimize import nnls as nnls_scipy
Expand All @@ -13,7 +23,7 @@ def test_nnls(rng):
x_glass = nnls_glass(a, b)
x_scipy, _ = nnls_scipy(a, b)

assert np.allclose(x_glass, x_scipy)
np.testing.assert_allclose(x_glass, x_scipy)

with pytest.raises(ValueError, match="input `a` is not a matrix"):
nnls_glass(b, a)
Expand Down

0 comments on commit bfd9e10

Please sign in to comment.