File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 1
1
import importlib .util
2
+ import types
2
3
3
4
import numpy as np
4
5
import pytest
6
+ from tests .conftest import array_api_compatible
5
7
6
8
from glass .core .algorithm import nnls as nnls_glass
7
9
8
10
# check if scipy is available for testing
9
11
HAVE_SCIPY = importlib .util .find_spec ("scipy" ) is not None
10
12
11
13
14
+ @array_api_compatible
12
15
@pytest .mark .skipif (not HAVE_SCIPY , reason = "test requires SciPy" )
13
- def test_nnls (rng : np .random .Generator ) -> None :
16
+ def test_nnls (rng : np .random .Generator , xp : types . ModuleType ) -> None :
14
17
from scipy .optimize import nnls as nnls_scipy
15
18
16
19
# cross-check output with scipy's nnls
17
20
18
- a = rng .standard_normal ((100 , 20 ))
19
- b = rng .standard_normal ((100 ,))
21
+ a = xp . asarray ( rng .standard_normal ((100 , 20 ) ))
22
+ b = xp . asarray ( rng .standard_normal ((100 ,) ))
20
23
21
24
x_glass = nnls_glass (a , b )
22
25
x_scipy , _ = nnls_scipy (a , b )
You can’t perform that action at this time.
0 commit comments