Skip to content
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 tests/test_ek0.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_attempt_step_y_shapes_reference(stepped_reference, d, num_derivatives):
def test_attempt_step_error_estimate_kronecker(stepped_kronecker, d):

assert isinstance(stepped_kronecker.error_estimate, jnp.ndarray)
assert stepped_kronecker.error_estimate.shape == (d,)
assert stepped_kronecker.error_estimate.shape == ()
assert jnp.all(stepped_kronecker.error_estimate >= 0)


Expand Down
2 changes: 1 addition & 1 deletion tornadox/ek0.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def initialize(self, ivp):
def compute_sigmasquared_error(P, Ql, z):
HQH = (P @ Ql @ Ql.T @ P.T)[1, 1]
sigma_squared = z.T @ z / HQH / z.shape[0]
error_estimate = jnp.stack([jnp.sqrt(sigma_squared * HQH)] * z.shape[0])
error_estimate = jnp.sqrt(sigma_squared * HQH)
return sigma_squared, error_estimate

@staticmethod
Expand Down
4 changes: 3 additions & 1 deletion tornadox/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def is_accepted(self, scaled_error_estimate):
return scaled_error_estimate < 1

def scale_error_estimate(self, unscaled_error_estimate, reference_state):
if unscaled_error_estimate.shape != reference_state.shape:
if (
not jnp.isscalar(unscaled_error_estimate.size)
) and unscaled_error_estimate.shape != reference_state.shape:
raise ValueError(
"Unscaled error estimate needs same shape as reference state."
)
Expand Down