2022-05-26 21:26:24 +00:00
|
|
|
import pytest
|
2022-07-31 10:00:45 +00:00
|
|
|
from pytest_pyodide import run_in_pyodide
|
2018-10-11 10:03:32 +00:00
|
|
|
|
|
|
|
|
2022-05-26 21:26:24 +00:00
|
|
|
@pytest.mark.driver_timeout(40)
|
|
|
|
@run_in_pyodide(packages=["scipy"])
|
2022-05-26 02:47:43 +00:00
|
|
|
def test_scipy_linalg(selenium):
|
2022-01-16 20:30:42 +00:00
|
|
|
import numpy as np
|
|
|
|
import scipy.linalg
|
|
|
|
from numpy.testing import assert_allclose
|
|
|
|
|
|
|
|
N = 10
|
|
|
|
X = np.random.RandomState(42).rand(N, N)
|
|
|
|
|
|
|
|
X_inv = scipy.linalg.inv(X)
|
|
|
|
|
|
|
|
res = X.dot(X_inv)
|
|
|
|
|
|
|
|
assert_allclose(res, np.identity(N), rtol=1e-07, atol=1e-9)
|
|
|
|
|
|
|
|
|
2022-05-26 21:26:24 +00:00
|
|
|
@pytest.mark.driver_timeout(40)
|
|
|
|
@run_in_pyodide(packages=["scipy"])
|
2022-05-26 02:47:43 +00:00
|
|
|
def test_brentq(selenium):
|
2022-01-16 20:30:42 +00:00
|
|
|
from scipy.optimize import brentq
|
|
|
|
|
|
|
|
brentq(lambda x: x, -1, 1)
|
|
|
|
|
|
|
|
|
2022-05-26 21:26:24 +00:00
|
|
|
@pytest.mark.driver_timeout(40)
|
|
|
|
@run_in_pyodide(packages=["scipy"])
|
2022-05-26 02:47:43 +00:00
|
|
|
def test_dlamch(selenium):
|
2022-01-16 20:30:42 +00:00
|
|
|
from scipy.linalg import lapack
|
|
|
|
|
|
|
|
lapack.dlamch("Epsilon-Machine")
|
|
|
|
|
|
|
|
|
2022-05-26 21:26:24 +00:00
|
|
|
@pytest.mark.driver_timeout(40)
|
|
|
|
@run_in_pyodide(packages=["scipy"])
|
2022-05-26 02:47:43 +00:00
|
|
|
def test_binom_ppf(selenium):
|
2022-01-16 20:30:42 +00:00
|
|
|
from scipy.stats import binom
|
|
|
|
|
|
|
|
assert binom.ppf(0.9, 1000, 0.1) == 112
|
Fix scipy linking errors (#2289)
With newer versions of emscripten, linker errors surface eariler.
This makes it easier to find function pointer cast errors without
having to execute the bad code path -- the errors happen when the
wasm modules are linked (at load time in the browser)
Anyways, this fixes more linker errors. Mostly the problems have
to do with LAPACK functions that take string arguments. Most
LAPACK functions that take string arguments use them as enums and
only care about the first character of the string. Because of the
way that f2c works, we need to replace these strings with the ascii
code of the first character so we should replace:
sTRSV( 'UPPER', 'NOTRANS', 'NONUNIT', J, H, LDH, Y, 1 )
==>
CALL sTRSV( 85, 78, 78, J, H, LDH, Y, 1 )
where 85 and 78 are the ascii codes of U and N. Various character
variables are subbed into being integer variables. The two
functions `ilaenv` and `xerbla` expect actual C strings as an
argument, but it is very annoying to produce C strings so instead
I added wrapper functions ilaenvf2c and xerblaf2c to clapack and
instead of calling ilaenv and xerbla we call the f2c versions.
2022-03-24 06:17:29 +00:00
|
|
|
|
|
|
|
|
2022-05-26 21:26:24 +00:00
|
|
|
@pytest.mark.driver_timeout(40)
|
2022-05-26 02:47:43 +00:00
|
|
|
@run_in_pyodide(packages=["pytest", "scipy-tests"])
|
|
|
|
def test_scipy_pytest(selenium):
|
Fix scipy linking errors (#2289)
With newer versions of emscripten, linker errors surface eariler.
This makes it easier to find function pointer cast errors without
having to execute the bad code path -- the errors happen when the
wasm modules are linked (at load time in the browser)
Anyways, this fixes more linker errors. Mostly the problems have
to do with LAPACK functions that take string arguments. Most
LAPACK functions that take string arguments use them as enums and
only care about the first character of the string. Because of the
way that f2c works, we need to replace these strings with the ascii
code of the first character so we should replace:
sTRSV( 'UPPER', 'NOTRANS', 'NONUNIT', J, H, LDH, Y, 1 )
==>
CALL sTRSV( 85, 78, 78, J, H, LDH, Y, 1 )
where 85 and 78 are the ascii codes of U and N. Various character
variables are subbed into being integer variables. The two
functions `ilaenv` and `xerbla` expect actual C strings as an
argument, but it is very annoying to produce C strings so instead
I added wrapper functions ilaenvf2c and xerblaf2c to clapack and
instead of calling ilaenv and xerbla we call the f2c versions.
2022-03-24 06:17:29 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
def runtest(module, filter):
|
|
|
|
pytest.main(
|
|
|
|
[
|
|
|
|
"--pyargs",
|
|
|
|
f"scipy.{module}",
|
|
|
|
"--continue-on-collection-errors",
|
|
|
|
"-vv",
|
|
|
|
"-k",
|
|
|
|
filter,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
runtest("odr", "explicit")
|
|
|
|
runtest("signal.tests.test_ltisys", "TestImpulse2")
|
|
|
|
runtest("stats.tests.test_multivariate", "haar")
|