surpyval 0.11 compatibility + conditional survival cs()#29
Merged
Conversation
non_repairable.py imported NonParametric, Parametric and ExactEventTime from submodule paths that were reorganised in surpyval 0.11. Import them from the top-level surpyval namespace instead, which works on both the old and new layouts, so RePyability can be used alongside the current surpyval that the Reliafy backend depends on. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013LT4iFs4HRQraP52HwVmgR
Bump the pinned dependencies to the latest surpyval (0.11.1), which requires numpy>=2.0,<3 and scipy>=1.13, and fix the incompatibilities that the newer surpyval/NumPy stack exposed: - NonRepairable._cost_rate: surpyval 0.11 returns 1-element arrays from sf/mean/qf, and scipy.optimize.minimize passes the time as a 1-element array. Coerce it to a float so the scipy.integrate.quad bound in avg_replacement_time() is a scalar (quad rejects array bounds). Fixes find_optimal_replacement() for parametric models. - NonRepairableRBD.random(): take the scalar from .random(1) before ordering the event queue and assigning into the output array (NumPy 2 rejects assigning a 1-element array to a scalar slot). Fixes the Monte-Carlo mean()/mean_time_to_failure(). - NonRepairableRBD.ff_by_node(): add the missing @check_x so it returns arrays like sf_by_node() rather than a scalar. Tests: relax the exact ff == 1 - sf assertion to approx (surpyval 0.11 computes ff(t) directly, so it can differ from 1 - sf(t) by a ULP), and add a system-level MTTF regression test. Full suite: 201 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013LT4iFs4HRQraP52HwVmgR
Implement cs(x, X) = sf(X + x) / sf(X) — the probability of surviving a further x given survival to X — as a first-class method: - a shared conditional_survival(model, x, X) helper (utils.wrappers) that works for anything exposing sf, clipping to [0, 1] and returning 0 where the item has all but surely failed by X; - NonRepairableRBD.cs (passes through sf() args like working/broken nodes and method); - StandbyModel, RepeatedNode, RepeatedStandbyNode; - PerfectReliability (always 1) and PerfectUnreliability (always 0). This matches SurPyval's own model.cs definition, so conditional survival can be computed uniformly across systems and every node type. Full suite: 201 passing plus a new cs test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013LT4iFs4HRQraP52HwVmgR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes RePyability work with the latest SurPyval and adds first-class conditional survival.
Changes
NonParametric/Parametric/ExactEventTimeimports; coerce scalars inNonRepairable._cost_rateandNonRepairableRBD.random()(NumPy 2 no longer accepts 1-element arrays as scalars); add the missing@check_xonff_by_node. Pins bumped tosurpyval==0.11.1,numpy>=2.0,<3.cs(x, X): probability of surviving a furtherxgiven survival toX, i.e.sf(X + x) / sf(X). Implemented as a sharedconditional_survival()helper and exposed onNonRepairableRBD,StandbyModel,RepeatedNode,RepeatedStandbyNode, and thePerfectReliability/PerfectUnreliabilityhelpers — matching SurPyval's ownmodel.csdefinition.Tests
Full suite: 201 passing, plus a new conditional-survival test and an updated tolerance for the now more-precise
ff.🤖 Generated with Claude Code
Generated by Claude Code