Skip to content

Commit

Permalink
test: updates for scipy convergence
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyPlanden committed Oct 4, 2024
1 parent 929f72d commit bac2447
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/unit/test_optimisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def dataset(self):
return pybop.Dataset(
{
"Time [s]": np.linspace(0, 360, 10),
"Current function [A]": 0.01 * np.ones(10),
"Current function [A]": 1e-3 * np.ones(10),
"Voltage [V]": np.ones(10),
}
)
Expand Down Expand Up @@ -134,12 +134,12 @@ def test_no_optimisation_parameters(self, model, dataset):
)
@pytest.mark.unit
def test_optimiser_kwargs(self, cost, optimiser):
optim = optimiser(cost=cost, maxiter=3, tol=1e-6)
optim = optimiser(cost=cost, maxiter=1, tol=1e-6)
cost_bounds = cost.parameters.get_bounds()

# Check maximum iterations
results = optim.run()
assert results.n_iterations == 3
assert results.n_iterations == 1

if optimiser in [pybop.GradientDescent, pybop.Adam, pybop.NelderMead]:
# Ignored bounds
Expand Down Expand Up @@ -552,11 +552,11 @@ def test_unphysical_result(self, cost):
@pytest.mark.unit
def test_optimsation_results(self, cost):
# Construct OptimisationResult
results = pybop.OptimisationResult(x=[0.55], cost=cost, n_iterations=1)
results = pybop.OptimisationResult(x=[1e-3], cost=cost, n_iterations=1)

# Asserts
assert results.x[0] == 0.55
assert results.final_cost == cost([0.55])
assert results.x[0] == 1e-3
assert results.final_cost == cost([1e-3])
assert results.n_iterations == 1

# Test non-finite results
Expand Down

0 comments on commit bac2447

Please sign in to comment.