Skip to content

surpyval 0.11 compatibility + conditional survival cs()#29

Merged
derrynknife merged 3 commits into
masterfrom
claude/rbd-repyability-backend-roqujl
Jun 18, 2026
Merged

surpyval 0.11 compatibility + conditional survival cs()#29
derrynknife merged 3 commits into
masterfrom
claude/rbd-repyability-backend-roqujl

Conversation

@derrynknife

Copy link
Copy Markdown
Owner

Makes RePyability work with the latest SurPyval and adds first-class conditional survival.

Changes

  • SurPyval 0.11 / NumPy 2 compatibility: fix the moved NonParametric/Parametric/ExactEventTime imports; coerce scalars in NonRepairable._cost_rate and NonRepairableRBD.random() (NumPy 2 no longer accepts 1-element arrays as scalars); add the missing @check_x on ff_by_node. Pins bumped to surpyval==0.11.1, numpy>=2.0,<3.
  • Conditional survival cs(x, X): probability of surviving a further x given survival to X, i.e. sf(X + x) / sf(X). Implemented as a shared conditional_survival() helper and exposed on NonRepairableRBD, StandbyModel, RepeatedNode, RepeatedStandbyNode, and the PerfectReliability/PerfectUnreliability helpers — matching SurPyval's own model.cs definition.

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

claude added 3 commits June 17, 2026 13:24
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
@derrynknife derrynknife merged commit 84b91c0 into master Jun 18, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants