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

Adds global parameter sensitivity analysis #635

Merged
merged 10 commits into from
Feb 3, 2025
Prev Previous commit
Next Next commit
tests: adds explicit dictionary type cost call
BradyPlanden committed Jan 29, 2025
commit 61ac28c1d7f8e82659a1665284c0b3dc6deb08e7
14 changes: 9 additions & 5 deletions tests/unit/test_cost.py
Original file line number Diff line number Diff line change
@@ -29,10 +29,12 @@ def ground_truth(self):

@pytest.fixture
def parameters(self):
return pybop.Parameter(
"Negative electrode active material volume fraction",
prior=pybop.Gaussian(0.5, 0.01),
bounds=[0.375, 0.625],
return pybop.Parameters(
pybop.Parameter(
"Negative electrode active material volume fraction",
prior=pybop.Gaussian(0.5, 0.01),
bounds=[0.375, 0.625],
)
)

@pytest.fixture
@@ -116,7 +118,8 @@ def test_base(self, model, parameters, dataset):
with pytest.raises(NotImplementedError):
base_cost([0.5])

def test_costs(self, cost):
def test_costs(self, cost, parameters):
# Test cost direction
if isinstance(cost, pybop.BaseLikelihood):
higher_cost = cost([0.52])
lower_cost = cost([0.55])
@@ -129,6 +132,7 @@ def test_costs(self, cost):

# Test type of returned value
assert np.isscalar(cost([0.5]))
assert np.isscalar(cost(parameters.as_dict()))

# Test UserWarnings
if isinstance(cost, (pybop.SumSquaredError, pybop.RootMeanSquaredError)):