|
11 | 11 | rng = np.random.default_rng(42849)
|
12 | 12 |
|
13 | 13 |
|
14 |
| -@pytest.mark.parametrize( |
15 |
| - "x, exc", |
16 |
| - [ |
17 |
| - ( |
18 |
| - ( |
19 |
| - pt.dmatrix(), |
20 |
| - (lambda x: x.T.dot(x))(rng.random(size=(3, 3)).astype("float64")), |
21 |
| - ), |
22 |
| - None, |
23 |
| - ), |
24 |
| - ( |
25 |
| - ( |
26 |
| - pt.lmatrix(), |
27 |
| - (lambda x: x.T.dot(x))(rng.poisson(size=(3, 3)).astype("int64")), |
28 |
| - ), |
29 |
| - None, |
30 |
| - ), |
31 |
| - ], |
32 |
| -) |
33 |
| -def test_Det(x, exc): |
34 |
| - x, test_x = x |
35 |
| - g = nlinalg.Det()(x) |
| 14 | +@pytest.mark.parametrize("dtype", ("float64", "int64")) |
| 15 | +@pytest.mark.parametrize("op", (nlinalg.Det(), nlinalg.SLogDet())) |
| 16 | +def test_Det_SLogDet(op, dtype): |
| 17 | + x = pt.matrix(dtype=dtype) |
36 | 18 |
|
37 |
| - cm = contextlib.suppress() if exc is None else pytest.warns(exc) |
38 |
| - with cm: |
39 |
| - compare_numba_and_py( |
40 |
| - [x], |
41 |
| - g, |
42 |
| - [test_x], |
43 |
| - ) |
| 19 | + rng = np.random.default_rng([50, sum(map(ord, dtype))]) |
| 20 | + x_ = rng.random(size=(3, 3)).astype(dtype) |
| 21 | + test_x = x_.T.dot(x_) |
44 | 22 |
|
| 23 | + g = op(x) |
45 | 24 |
|
46 |
| -@pytest.mark.parametrize( |
47 |
| - "x, exc", |
48 |
| - [ |
49 |
| - ( |
50 |
| - ( |
51 |
| - pt.dmatrix(), |
52 |
| - (lambda x: x.T.dot(x))(rng.random(size=(3, 3)).astype("float64")), |
53 |
| - ), |
54 |
| - None, |
55 |
| - ), |
56 |
| - ( |
57 |
| - ( |
58 |
| - pt.lmatrix(), |
59 |
| - (lambda x: x.T.dot(x))(rng.poisson(size=(3, 3)).astype("int64")), |
60 |
| - ), |
61 |
| - None, |
62 |
| - ), |
63 |
| - ], |
64 |
| -) |
65 |
| -def test_SLogDet(x, exc): |
66 |
| - x, test_x = x |
67 |
| - g = nlinalg.SLogDet()(x) |
68 |
| - |
69 |
| - cm = contextlib.suppress() if exc is None else pytest.warns(exc) |
70 |
| - with cm: |
71 |
| - compare_numba_and_py( |
72 |
| - [x], |
73 |
| - g, |
74 |
| - [test_x], |
75 |
| - ) |
| 25 | + compare_numba_and_py([x], g, [test_x]) |
76 | 26 |
|
77 | 27 |
|
78 | 28 | # We were seeing some weird results in CI where the following two almost
|
|
0 commit comments