Skip to main content

A Python toolkit for reliability analysis (MTTF, Weibull) with CI/CD.

Project description

PyReliabilityPro: A Python Toolkit for Reliability Analysis

Python CI Pipeline codecov

PyReliabilityPro is a lightweight, open-source Python toolkit designed for engineers, data scientists, and students to perform common reliability engineering calculations and analyses. The project focuses on providing a clean, intuitive API for statistical analysis of failure data, backed by a robust, modern development workflow.

This project was developed as a comprehensive portfolio piece to showcase skills in Python software development, Test-Driven Development (TDD), Quality Assurance (QA) best practices, and CI/CD automation with GitHub Actions.


Key Features

  • Weibull Distribution Analysis:
    • Parameter Estimation: Estimate 2-parameter (beta, eta) or 3-parameter (beta, eta, gamma) Weibull parameters from failure data using Maximum Likelihood Estimation (MLE) via scipy.stats.
    • Descriptive Functions: Calculate the Probability Density Function (PDF), Cumulative Distribution Function (CDF), Survival Function (SF), and Hazard Function (HF).
  • Reliability Metrics:
    • Calculate the theoretical Mean Time To Failure (MTTF) for a given Weibull distribution.
    • Calculate the sample MTTF for data assumed to follow an exponential distribution.
  • Exceptional Code Quality & QA Focus:
    • High Test Coverage: Achieved over 95% code coverage with a comprehensive suite of unit tests using pytest. Tests cover normal functionality, edge cases, and input validations.
    • Static Analysis: The codebase is automatically checked for code style (flake8), formatting consistency (black), and type safety (mypy) on every commit.
  • Modern CI/CD Pipeline:
    • A full-featured Continuous Integration pipeline built with GitHub Actions.
    • Automated Workflow: On every push and pull request to the main branch, the pipeline automatically:
      1. Installs dependencies.
      2. Runs linters and formatters to check code quality.
      3. Executes the entire test suite across multiple Python versions (3.8, 3.9, 3.10, 3.11).
      4. Generates a code coverage report and uploads it to Codecov for analysis and visualization.

Installation

(Note: Once published to PyPI, this will be the primary installation method.)

To install PyReliabilityPro, you can use pip:

pip install pyreliabilitypro 

Alternatively, to install the latest development version directly from GitHub:

pip install git+https://github.com/Santtoh19/PyReliabilityPro.git

Quick Start / Usage Example

Here's a simple example of how to use the toolkit to fit a 2-parameter Weibull distribution to some failure data and then analyze it.

import pyreliabilitypro as rel
import numpy as np

# 1. Sample failure data (e.g., in hours)
failure_times = [105, 120, 135, 160, 175, 190, 210, 230, 255, 280]

# 2. Estimate the 2-parameter Weibull parameters from the data
# The weibull_fit function returns (beta, eta, gamma)
# For a 2P fit, gamma will be 0.0.
try:
    beta_est, eta_est, _ = rel.weibull_fit(failure_times)
    print(f"Estimated Beta (Shape): {beta_est:.2f}")
    print(f"Estimated Eta (Scale / Characteristic Life): {eta_est:.2f} hours")

    # 3. Use the estimated parameters to analyze reliability
    
    # Calculate the probability of failure by 150 hours (CDF)
    prob_fail_by_150 = rel.weibull_cdf(x=150, beta=beta_est, eta=eta_est)
    print(f"Probability of failure by 150 hours: {prob_fail_by_150:.2%}")

    # Calculate the reliability (probability of survival) at 150 hours (SF)
    reliability_at_150 = rel.weibull_sf(x=150, beta=beta_est, eta=eta_est)
    print(f"Reliability (survival probability) at 150 hours: {reliability_at_150:.2%}")

    # Calculate the instantaneous failure rate (hazard rate) at 150 hours
    hazard_at_150 = rel.weibull_hf(x=150, beta=beta_est, eta=eta_est)
    print(f"Hazard Rate at 150 hours: {hazard_at_150:.4f} (failures/hour)")

    # Calculate the Mean Time To Failure (MTTF) for this distribution
    mttf = rel.weibull_mttf(beta=beta_est, eta=eta_est)
    print(f"Calculated MTTF for this distribution: {mttf:.2f} hours")

except ValueError as e:
    print(f"An error occurred: {e}")

Development & Contribution

This project is built with modern Python development practices. To set up a local development environment: Clone the repository:

git clone https://github.com/Santtosh19/PyReliabilityPro.git
cd PyReliabilityPro

Create and activate a virtual environment:

python -m venv .venv
# On Windows (PowerShell):
# .\.venv\Scripts\Activate.ps1
# On macOS/Linux:
# source .venv/bin/activate

Install all dependencies:

pip install -r requirements.txt
pip install -r requirements-dev.txt

Run checks and tests locally:

# Run code style and quality checks
flake8 .
black --check .
mypy pyreliabilitypro --ignore-missing-imports

# Run the full test suite
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyreliabilitypro-0.2.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyreliabilitypro-0.2.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file pyreliabilitypro-0.2.0.tar.gz.

File metadata

  • Download URL: pyreliabilitypro-0.2.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyreliabilitypro-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6e9408b6a51cdf992db0958344574c5b70223c56f04ec2398815c5b13095e2fe
MD5 a8236b0b1a2a809b0c15f7810c16a23e
BLAKE2b-256 b7e0370549d5fd53571f69dbb34b6ceb975db89cc8e26458a749149efcc2726c

See more details on using hashes here.

File details

Details for the file pyreliabilitypro-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyreliabilitypro-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39ac8786d503affbcefae56c980c60403739aa320796c68bf96405bbc5da06ad
MD5 168136391d66405a40ef343ad3029a5a
BLAKE2b-256 823781357290ef4d5b53d057d9e5a17e2c00186535d37e413014d99f0e25a953

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page