Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jan 27, 2025
1 parent 672cdc2 commit fb280b9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/unit/test_likelihoods.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,27 @@ def test_scaled_log_likelihood(self, one_signal_problem):

@pytest.mark.unit
def test_observed_fisher(self, one_signal_problem):
likelihood = pybop.GaussianLogLikelihoodKnownSigma(one_signal_problem, sigma0=0.1)

likelihood = pybop.GaussianLogLikelihoodKnownSigma(
one_signal_problem, sigma0=0.1
)

# Create mock data and sensitivities
y = {"Voltage [V]": np.array([3.7, 3.6, 3.5])}
dy = np.array([[0.1, 0.2, 0.3]])

# Compute observed Fisher Information Matrix
fim = likelihood.observed_fisher(y, dy)

# Check that FIM is a 1x1 array (since we have one parameter)
assert fim.shape == (1, 1)

# Check that FIM is positive (for a single parameter, it should be)
assert fim[0, 0] > 0

# Check that FIM is computed correctly
expected_fim = np.sum(np.square(dy)) / likelihood.n_data
np.testing.assert_allclose(fim, expected_fim, rtol=1e-7)

# Test without providing dy
fim_without_dy = likelihood.observed_fisher(y)
assert fim_without_dy.shape == (1, 1)
Expand Down

0 comments on commit fb280b9

Please sign in to comment.