From 0086628dd3a8242b5bc2bb2997f223c736bd50a1 Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 10:51:13 +0100
Subject: [PATCH 1/9] update README
---
README.md | 45 ++++++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index 46deca2..f6bbdf1 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,24 @@
REACT_RS
+[](https://github.com/DNYFZR/react-rs/actions/workflows/test.yml) [](https://github.com/DNYFZR/react-rs/actions/workflows/build.yml)
+
## **Summary**
React_rs (reactors) is Python package with Rust backend functionality for executing Discrete Event simulations in a fast & cost efficient way.
-- Exposed Rust functions have a corresponding Python function in the [API definition](python/react_rs/__init__.py) which allows the application to convert the Rust polars DataFrame into a Python polars DataFrame & vice versa.
-
-- There are also native Python components to the package, which are in dedicated scripts in the [Python directory](python/react_rs).
-
The core functionality of the app is :
- Fit, adjust & generate of a range of Weibull model survival curves
-- Simulation of discrete events over a user-defined number of timesteps & simulations based on the survival curve in the probabilities column of the input dataset - these can be from the internal Weibull module, or from any other user-defined model
+- Simulation of discrete events over a user-defined number of timesteps & simulations based on the survival curve in the probabilities column of the input dataset
+
+ - Survival curves can be from the internal Weibull module, or from any other user-defined model, so long as there is a column in the input table & its name is defined under 'probs_col' (see example below)
-- Application of financial limits to simulation outputs, and reallocation of replacement events in line with these limits
+- Application of financial constraints to simulation outputs, with randomised reallocation of replacement events in line with each timestep limit
-- Event or cost based aggregations are summaries of the totals for each simulation & timestep
+- Event & cost based aggregations showing a summary of totals for each simulation & timestep
-- Profile based aggregation creates a summary of the count of items ages at each timestep within each simulation iteration
+- Profile based aggregation creates a count of item ages at each timestep within each iteration
## **Usage**
@@ -41,14 +41,17 @@ for model, params in model_config.items():
# Fit method auto-handles base model & adjustments to mean
wb.fit(model_name=model, **params)
-# Generate survival curve DataFrame under 'curves' attribute
+# Generate survival curve dictionary under 'curves' attribute
wb.generate()
-# Join survival curves DataFrame to input DataFrame
+# Join survival curves to input DataFrame
df = pl.read_parquet("./tests/data/input.parquet").join(
- pl.DataFrame({"model": wb.curves.keys(), "curve": wb.curves.values()}),
- "model",
- "left",
+ other=pl.DataFrame({
+ "model": wb.curves.keys(),
+ "curve": wb.curves.values()
+ }),
+ on="model",
+ how="left",
)
# Execute simulation in Rust
@@ -60,7 +63,7 @@ sim_result = react_rs.simulate(
probs_col="curve",
n_sims=100,
n_steps=50,
- parallel_limit=10,
+ parallel_limit=10, # control concurrent parallel operations
)
# Constrain simulation output in Rust
@@ -68,19 +71,19 @@ sim_result_constrained = react_rs.constrain(
df=sim_result,
constrain_steps=30, # limit steps taken through constraint system
iter_regex="step",
- cost_col="cost",
- constraints=[int(50e6) for _ in range(30)],
+ cost_col="cost", # name is standardised to 'cost' by simulate function
+ constraints=[int(50e6) for _ in range(30)],
partition_by="sim_id",
parallel_limit=10,
)
-# Aggregate simulation outputs
+# Aggregate simulation outputs)
sim_result_agg = react_rs.aggregate(
df=sim_result,
partition_by="sim_id",
iter_regex="step",
target_value=0,
- cost_col="cost", # None if events are req'd
+ cost_col="cost", # set to None if events are req'd
)
sim_result_const_agg = react_rs.aggregate(
@@ -107,6 +110,10 @@ sim_constrained_profile = react_rs.profile(
## **Development**
+- Exposed Rust functions have a corresponding Python function in the [API definition](python/react_rs/__init__.py) which mirrors the input structure of the Rust function & returns its output. Should there be an error while running the function, the Rust errors will be propogated back to the user.
+
+- There are native Python components to the package, which are in dedicated scripts in the [Python directory](python/react_rs).
+
### **Build**
The [build workflow](.github/workflows/build.yml) is configured to build for Windows, Linux & MacOS :
@@ -125,4 +132,4 @@ These tests call all of the functionality within the native Python code & the Ru
### **Notes**
-- When working on [__init__.py](python/react_rs/__init__.py), your IDE may highlight imports from the react_rs package with an error - this is normal and can be ignored.
+- If working on the [Python API](python/react_rs/__init__.py), your IDE may highlight imports from the react_rs package with an error - this is normal and can be ignored.
From c83bef9354bca3ca752465e1d89a5bd564c7bc86 Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 10:53:41 +0100
Subject: [PATCH 2/9] update build trigger
---
.github/workflows/build.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index dea0f70..960788d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,6 +1,8 @@
name: Build
-on: [push]
+on:
+ push:
+ branches: ["main"]
env:
CARGO_TERM_COLOR: always
From fd58abf261253348b1175f64476e1e1115acaa91 Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 10:54:29 +0100
Subject: [PATCH 3/9] update version
---
Cargo.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Cargo.toml b/Cargo.toml
index 70fbe66..0e057e8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-version = "0.9.2"
+version = "0.9.3"
name = "react-rs"
edition = "2024"
From c746fd95fddb63b686d3ff324978fc9f88255348 Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 10:58:10 +0100
Subject: [PATCH 4/9] update test setup
---
.github/workflows/test.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 86391d2..5f289ec 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -17,13 +17,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- - uses: actions-rust-lang/setup-rust-toolchain@stable
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- run: pip install -r pyproject.toml
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@stable
+
- name: Install app via Maturin
uses: PyO3/maturin-action@v1
with:
From 6b010a8e849bf5c9c4a57bc486c8d02430c7afab Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 11:01:03 +0100
Subject: [PATCH 5/9] update test setup
---
.github/workflows/test.yml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 5f289ec..e5652ba 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -17,13 +17,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- - uses: actions/setup-python@v6
+
+ - name: Setup Python
+ uses: actions/setup-python@v6
with:
python-version: "3.12"
- cache: pip
- - run: pip install -r pyproject.toml
- - name: Install Rust
+ - name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install app via Maturin
From da0049864f31a1dcf59ffb294a84be6c57f38dbb Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 11:02:47 +0100
Subject: [PATCH 6/9] update python setup
---
.github/workflows/test.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index e5652ba..ffa6252 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -23,6 +23,9 @@ jobs:
with:
python-version: "3.12"
+ - name: Setup Python env
+ run: python -m venv .venv
+
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
From e6494a6c41d5f9352973796d43eb2a0dfc06a5c1 Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 11:14:16 +0100
Subject: [PATCH 7/9] update test build
---
.github/workflows/test.yml | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index ffa6252..e9c1e4e 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -29,12 +29,15 @@ jobs:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- - name: Install app via Maturin
+ - name: Build app via Maturin
uses: PyO3/maturin-action@v1
with:
- command: develop
+ command: build
args: --release
+ - name: Install app
+ run: python -m pip install target\wheels\react_rs*.whl
+
- name: Install Python test dependencies
run: pip install pytest mock codecov pydocstyle pytest-cov pylint pylint_junit
From f98714dca133fe18f131d84b33b33b0a30540af6 Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 12:08:47 +0100
Subject: [PATCH 8/9] Update test.yml
---
.github/workflows/test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index e9c1e4e..22243ce 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -36,7 +36,7 @@ jobs:
args: --release
- name: Install app
- run: python -m pip install target\wheels\react_rs*.whl
+ run: python -m pip install target/wheels/react_rs*.whl
- name: Install Python test dependencies
run: pip install pytest mock codecov pydocstyle pytest-cov pylint pylint_junit
From ad4176651c0c40e74cf8c662fa3e8e18264520f7 Mon Sep 17 00:00:00 2001
From: Danny <76977155+DNYFZR@users.noreply.github.com>
Date: Thu, 18 Jun 2026 12:18:09 +0100
Subject: [PATCH 9/9] update test imports
---
tests/test_weibull.py | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/tests/test_weibull.py b/tests/test_weibull.py
index 609ef61..5bb2a21 100644
--- a/tests/test_weibull.py
+++ b/tests/test_weibull.py
@@ -1,12 +1,7 @@
# Weibull Module Test Script
-import sys
-
import numpy as np
import pytest
-
-sys.path.append("..")
-
-from python.react_rs._weibull import Weibull
+from react_rs import Weibull
test_case = [
{