Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unpin numpy since scikits is fixed #2231

Merged
merged 2 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Requirements for readthedocs.io
numpy <= 1.22 # change back to numpy>=1.16 once scikit.odes is fixed
numpy >= 1.16
scipy >= 1.3
pandas >= 0.24
anytree >= 2.4.3
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy <= 1.22 # change back to numpy>=1.16 once scikit.odes is fixed
numpy >= 1.16
scipy >= 1.3
pandas >= 0.24
anytree >= 2.4.3
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def compile_KLU():
python_requires=">=3.7,<3.10",
# List of dependencies
install_requires=[
"numpy<=1.22", # change back to numpy>=1.16 once scikit.odes is fixed
"numpy>=1.16",
"scipy>=1.3",
"pandas>=0.24",
"anytree>=2.4.3",
Expand Down
9 changes: 7 additions & 2 deletions tests/unit/test_expression_tree/test_binary_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
import sympy
from scipy.sparse.coo import coo_matrix
from scipy.sparse import coo_matrix

import pybamm

Expand Down Expand Up @@ -360,7 +360,12 @@ def test_softminus_softplus(self):
self.assertAlmostEqual(maximum.evaluate(y=np.array([2]))[0, 0], 2)
self.assertAlmostEqual(maximum.evaluate(y=np.array([0]))[0, 0], 1)
self.assertEqual(
str(maximum), "log(5.184705528587072e+21 + exp(50.0 * y[0:1])) / 50.0"
str(maximum)[:15],
"log(5.184705528587072e+21 + exp(50.0 * y[0:1])) / 50.0"[:15],
)
self.assertEqual(
str(maximum)[-33:],
"log(5.184705528587072e+21 + exp(50.0 * y[0:1])) / 50.0"[-33:],
)

# Test that smooth min/max are used when the setting is changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_special_functions(self):
np.arccosh,
np.arcsinh,
]:
self.assert_casadi_equal(
self.assert_casadi_almost_equal(
pybamm.Function(np_fun, c).to_casadi(), casadi.MX(np_fun(3)), evalf=True
)

Expand All @@ -137,9 +137,7 @@ def test_special_functions(self):
# pybamm.Function(np_fun, c).to_casadi()
# ) - casadi.evalf(casadi.MX(np_fun(3)))
# is not zero, but a small number of the order 10^-15 when np_func is np.cosh
for np_fun in [
np.cosh
]:
for np_fun in [np.cosh]:
self.assert_casadi_almost_equal(
pybamm.Function(np_fun, c).to_casadi(),
casadi.MX(np_fun(3)),
Expand Down Expand Up @@ -196,9 +194,11 @@ def test_interpolation(self):
interp_casadi = interp.to_casadi(y=casadi_y)

# error for converted children count
y3 = (pybamm.StateVector(slice(0, 1)),
pybamm.StateVector(slice(0, 1)),
pybamm.StateVector(slice(0, 1)))
y3 = (
pybamm.StateVector(slice(0, 1)),
pybamm.StateVector(slice(0, 1)),
pybamm.StateVector(slice(0, 1)),
)
x3_ = [np.linspace(0, 1) for _ in range(3)]
x3 = np.column_stack(x3_)
data3 = 2 * x3 # np.tile(2 * x3, (10, 1)).T
Expand All @@ -218,18 +218,14 @@ def test_interpolation_2d(self):
y_test = np.array([0.4, 0.6])
Y = (2 * x).sum(axis=1).reshape(*[len(el) for el in x_])
for interpolator in ["linear"]:
interp = pybamm.Interpolant(x_,
Y,
y, interpolator=interpolator)
interp = pybamm.Interpolant(x_, Y, y, interpolator=interpolator)
interp_casadi = interp.to_casadi(y=casadi_y)
f = casadi.Function("f", [casadi_y], [interp_casadi])
np.testing.assert_array_almost_equal(interp.evaluate(y=y_test), f(y_test))
# square
y = (pybamm.StateVector(slice(0, 1)), pybamm.StateVector(slice(0, 1)))
Y = (x ** 2).sum(axis=1).reshape(*[len(el) for el in x_])
interp = pybamm.Interpolant(x_,
Y,
y, interpolator="linear")
interp = pybamm.Interpolant(x_, Y, y, interpolator="linear")
interp_casadi = interp.to_casadi(y=casadi_y)
f = casadi.Function("f", [casadi_y], [interp_casadi])
np.testing.assert_array_almost_equal(interp.evaluate(y=y_test), f(y_test))
Expand Down