Skip to content

Commit

Permalink
resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Odland committed Nov 30, 2023
2 parents f0b3819 + b9da2de commit 6577385
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/iterative_ensemble_smoother/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
features of iterative_ensemble_smoother
"""
import numbers
import warnings
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union

import numpy as np
Expand Down Expand Up @@ -158,9 +159,16 @@ def _correlation_matrix(
np.newaxis, :
]

# Perform checks
assert corr_XY.max() <= 1
assert corr_XY.min() >= -1
# Perform checks. There appears to be occasional numerical issues in
# the equation. With 2 ensemble members, we get e.g. a max value of
# 1.0000000000016778. We allow some leeway and clip the results.
eps = 1e-8
if not ((corr_XY.max() <= 1 + eps) and (corr_XY.min() >= -1 - eps)):
msg = "Cross-correlation matrix has entries not in [-1, 1]."
msg += f"The min and max values are: {corr_XY.min()} and {corr_XY.max()}"
warnings.warn(msg)

corr_XY = np.clip(corr_XY, a_min=-1, a_max=1)
return corr_XY

def assimilate(
Expand Down

0 comments on commit 6577385

Please sign in to comment.