2018-10-11 10:03:32 +00:00
|
|
|
from textwrap import dedent
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2018-10-31 14:06:08 +00:00
|
|
|
def test_scipy_linalg(selenium_standalone, request):
|
2018-10-11 10:03:32 +00:00
|
|
|
selenium = selenium_standalone
|
2018-10-15 14:36:06 +00:00
|
|
|
|
2020-06-28 18:24:40 +00:00
|
|
|
if selenium.browser == "chrome":
|
|
|
|
request.applymarker(pytest.mark.xfail(run=False, reason="chrome not supported"))
|
2018-10-11 10:03:32 +00:00
|
|
|
|
2018-10-25 13:29:13 +00:00
|
|
|
selenium.load_package("scipy")
|
2020-06-28 18:24:40 +00:00
|
|
|
cmd = dedent(
|
|
|
|
r"""
|
2018-10-25 13:29:13 +00:00
|
|
|
import numpy as np
|
|
|
|
import scipy as sp
|
|
|
|
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)
|
2020-06-28 18:24:40 +00:00
|
|
|
"""
|
|
|
|
)
|
2018-10-25 13:29:13 +00:00
|
|
|
|
|
|
|
selenium.run(cmd)
|
2019-06-19 18:26:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_brentq(selenium_standalone):
|
|
|
|
selenium_standalone.load_package("scipy")
|
|
|
|
selenium_standalone.run("from scipy.optimize import brentq")
|
|
|
|
selenium_standalone.run("brentq(lambda x: x, -1, 1)")
|