Skip to content

Commit

Permalink
fix check in EOCRecorder
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Oct 31, 2021
1 parent 6da40e3 commit 688d007
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pytools/convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ def __init__(self):
self.history: List[Tuple[float, float]] = []

def add_data_point(self, abscissa: float, error: float) -> None:
from numbers import Number
if not isinstance(abscissa, Number):
if not (np.isscalar(abscissa)
or (isinstance(abscissa, np.ndarray) and abscissa.shape == ())):
raise TypeError(
f"'abscissa' is not a number: '{type(abscissa).__name__}'")
f"'abscissa' is not a scalar: '{type(abscissa).__name__}'")

if not isinstance(error, Number):
raise TypeError(f"'error' is not a number: '{type(error).__name__}'")
if not (np.isscalar(error)
or (isinstance(error, np.ndarray) and error.shape == ())):
raise TypeError(f"'error' is not a scalar: '{type(error).__name__}'")

self.history.append((abscissa, error))

Expand Down

0 comments on commit 688d007

Please sign in to comment.