From f4342db5c47220de17c3f4a8c1eee71806549926 Mon Sep 17 00:00:00 2001 From: Mark Messner Date: Tue, 10 Jun 2025 21:14:26 -0500 Subject: [PATCH 1/3] Need to extend bound fix --- pycreep/ttp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycreep/ttp.py b/pycreep/ttp.py index d40d282..cb6d19c 100644 --- a/pycreep/ttp.py +++ b/pycreep/ttp.py @@ -253,7 +253,7 @@ def predict_time(self, stress, temperature, confidence=None): if confidence is None: h = 0.0 else: - h = scipy.stats.norm.interval(confidence)[1] + h = np.sign(confidence) * scipy.stats.norm.interval(np.abs(confidence))[1] return 10.0 ** ( self.time_sign From 2b4730d2a02730f1e5e43893761b6691974bee42 Mon Sep 17 00:00:00 2001 From: Mark Messner Date: Mon, 23 Jun 2025 12:51:08 -0500 Subject: [PATCH 2/3] More bugfixes for AMMT demo --- pycreep/gpr.py | 2 +- pycreep/ttp.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pycreep/gpr.py b/pycreep/gpr.py index 423f2c5..33429d6 100644 --- a/pycreep/gpr.py +++ b/pycreep/gpr.py @@ -369,7 +369,7 @@ def predict_log_stress(self, time, temperature): return mean.numpy(), var.numpy() - def predict_stress(self, time, temperature, confidence=None): + def predict_stress(self, time, temperature, confidence=None, **kwargs): """ Predict the stress at a given time and temperature diff --git a/pycreep/ttp.py b/pycreep/ttp.py index cb6d19c..8b138c5 100644 --- a/pycreep/ttp.py +++ b/pycreep/ttp.py @@ -262,7 +262,7 @@ def predict_time(self, stress, temperature, confidence=None): ) ) - def predict_stress(self, time, temperature, confidence=None, root_bounds=None): + def predict_stress(self, time, temperature, confidence=None, root_bounds=None, raise_on_error = True): """ Predict new values of stress given time and temperature @@ -275,6 +275,7 @@ def predict_stress(self, time, temperature, confidence=None, root_bounds=None): average predictions root_bounds: if not None, lower and upper bounds on which root value to use when inverting the TTP polynomial + raise_on_error: if true throw an error if we can't invert. if not return nan """ # Will want these sorted if root_bounds is not None: @@ -298,7 +299,10 @@ def solve_one(x): pi[-1] -= x rs = np.array(np.roots(pi)) if np.all(np.abs(np.imag(rs)) > 0): - raise ValueError("Inverting relation to predict stress failed") + if raise_on_error: + raise ValueError("Inverting relation to predict stress failed") + else: + return np.nan rs[np.abs(np.imag(rs)) > 0] = 0 rs = np.real(rs) # Need to consider this... @@ -306,7 +310,10 @@ def solve_one(x): return np.max(rs) val = np.logical_and(rs >= root_bounds[0], rs <= root_bounds[1]) if np.all(np.logical_not(val)): - raise ValueError("No root falls within user provided bounds!") + if raise_on_error: + raise ValueError("No root falls within user provided bounds!") + else: + return np.nan return rs[val][0] # Solve each one, one at a time, for now From 262bdc9ebdc14cbd7904b35b66cf30180e682d8a Mon Sep 17 00:00:00 2001 From: Mark Messner Date: Tue, 24 Jun 2025 11:51:03 -0500 Subject: [PATCH 3/3] Linting fixes --- pycreep/gpr.py | 1 + pycreep/ttp.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pycreep/gpr.py b/pycreep/gpr.py index 33429d6..bf35ecf 100644 --- a/pycreep/gpr.py +++ b/pycreep/gpr.py @@ -369,6 +369,7 @@ def predict_log_stress(self, time, temperature): return mean.numpy(), var.numpy() + # pylint: disable=unused-argument def predict_stress(self, time, temperature, confidence=None, **kwargs): """ Predict the stress at a given time and temperature diff --git a/pycreep/ttp.py b/pycreep/ttp.py index 8b138c5..8ae9796 100644 --- a/pycreep/ttp.py +++ b/pycreep/ttp.py @@ -262,7 +262,9 @@ def predict_time(self, stress, temperature, confidence=None): ) ) - def predict_stress(self, time, temperature, confidence=None, root_bounds=None, raise_on_error = True): + def predict_stress( + self, time, temperature, confidence=None, root_bounds=None, raise_on_error=True + ): """ Predict new values of stress given time and temperature @@ -301,8 +303,7 @@ def solve_one(x): if np.all(np.abs(np.imag(rs)) > 0): if raise_on_error: raise ValueError("Inverting relation to predict stress failed") - else: - return np.nan + return np.nan rs[np.abs(np.imag(rs)) > 0] = 0 rs = np.real(rs) # Need to consider this... @@ -312,8 +313,7 @@ def solve_one(x): if np.all(np.logical_not(val)): if raise_on_error: raise ValueError("No root falls within user provided bounds!") - else: - return np.nan + return np.nan return rs[val][0] # Solve each one, one at a time, for now