Skip to main content

A personal utility package by Shivsamb Harkare.

Project description

shivs_per_lib

A Python utility library developed by Shivsamb Harkare (COEP Technological University) for engineering, embedded systems, digital electronics, signal processing, control systems, AI/ML, and software development applications.

The goal of this library is to provide a collection of commonly used engineering calculations, signal processing utilities, machine learning helpers, and embedded-system tools in a single easy-to-use package.


Installation

pip install shivs_per_lib

Modules Overview

The library contains functions from the following domains:

  • Digital Electronics
  • DSP (Digital Signal Processing)
  • Control Systems
  • Embedded Systems
  • AI & Machine Learning
  • EDA (Exploratory Data Analysis)
  • Software Development Utilities

Digital Electronics

q_mc()

Implements the Quine-McCluskey Boolean minimization algorithm.

Purpose

Used to simplify Boolean expressions and minimize logic circuits.

Example

from shivs_per_lib import q_mc

q_mc()

The function asks for:

  • Minterms
  • Don't-care terms
  • Number of variables

and outputs the simplified Boolean expression.


binary_to_gray()

Converts a binary number into Gray code.

Example

binary_to_gray("1010")

Output:

1111

Applications

  • Rotary encoders
  • Digital communication
  • Error reduction systems

binary_to_decimal()

Converts binary to decimal.

binary_to_decimal("1010")

Output:

10

decimal_to_binary()

Converts decimal to binary.

decimal_to_binary(10)

Output:

1010

DSP Functions

fft_analysis()

Performs Fast Fourier Transform analysis.

Example

freq, magnitude = fft_analysis(signal, 1000)

Returns

  • Frequency components
  • FFT magnitude spectrum

Applications

  • Vibration analysis
  • Audio processing
  • Biomedical signals
  • IMU analysis

butter_lowpass()

Applies Butterworth low-pass filtering.

Example

filtered = butter_lowpass(
    signal,
    cutoff=20,
    fs=100
)

Applications

  • Sensor noise removal
  • ECG filtering
  • IMU preprocessing

butter_highpass()

Applies Butterworth high-pass filtering.

Example

filtered = butter_highpass(
    signal,
    cutoff=1,
    fs=100
)

moving_average()

Smooths signals using moving average filtering.

Example

moving_average(signal, window=5)

rms()

Computes Root Mean Square value.

Example

rms(signal)

Applications

  • Power calculations
  • Vibration analysis
  • Signal energy estimation

Control Systems

pid_control()

Implements PID control calculations.

Example

output, integral, error = pid_control(
    setpoint=100,
    measured=95,
    kp=1.2,
    ki=0.3,
    kd=0.1,
    integral=0,
    prev_error=0,
    dt=0.01
)

Applications

  • Temperature control
  • Motor speed control
  • Process automation

first_order_response()

Calculates first-order system response.

first_order_response(
    K=1,
    tau=2,
    time=t
)

percent_overshoot()

Calculates percentage overshoot.

percent_overshoot(peak=120, final=100)

Output:

20

steady_state_error()

Computes steady-state error.

steady_state_error(
    reference=100,
    output=98
)

Output:

2

Embedded Systems

adc_to_voltage()

Converts ADC counts to voltage.

adc_to_voltage(
    adc_value=2048,
    resolution=12,
    vref=3.3
)

voltage_divider()

Calculates voltage divider output.

voltage_divider(
    vin=12,
    r1=1000,
    r2=1000
)

Output:

6V

ohms_law()

Solves Ohm's Law.

ohms_law(v=12, r=4)

Output:

3A

pwm_duty_cycle()

Calculates PWM duty cycle.

pwm_duty_cycle(
    on_time=2,
    period=10
)

Output:

20%

timer_frequency()

Calculates timer frequency.

timer_frequency(
    16000000,
    64
)

uart_tx_time()

Computes UART transmission time.

uart_tx_time(
    bytes_count=100,
    baudrate=9600
)

battery_runtime()

Estimates battery runtime.

battery_runtime(
    2000,
    500
)

Output:

4 Hours

crc8()

Computes CRC-8 checksum.

crc8([1,2,3,4])

Applications

  • Communication protocols
  • Error detection
  • Embedded systems

debounce()

Debounces noisy digital signals.

debounce(samples)

byte_to_hex()

Converts byte to hexadecimal.

byte_to_hex(255)

Output:

0xff

hex_to_binary()

Converts hexadecimal to binary.

hex_to_binary("FF")

swap_endian_16()

Swaps endianness of a 16-bit value.

swap_endian_16(0x1234)

Output:

0x3412

AI & Machine Learning

normalize()

Performs Z-score normalization.

normalize(data)

minmax_normalize()

Performs Min-Max normalization.

minmax_normalize(data)

sliding_window()

Creates overlapping windows.

sliding_window(
    data,
    window_size=128,
    step=64
)

Applications

  • Gait analysis
  • HAR systems
  • Time-series ML

quaternion_magnitude()

Computes quaternion magnitude.

quaternion_magnitude(
    w,x,y,z
)

train_test_split()

Randomly splits data.

train_test_split(
    data,
    test_size=0.2
)

accuracy_score()

Computes classification accuracy.

accuracy_score(
    y_true,
    y_pred
)

mae()

Computes Mean Absolute Error.

mae(
    y_true,
    y_pred
)

confusion_matrix()

Creates confusion matrix metrics.

confusion_matrix(
    y_true,
    y_pred
)

Returns:

{
    "TP": ...,
    "TN": ...,
    "FP": ...,
    "FN": ...
}

missing_percentage()

Computes percentage of missing values.

missing_percentage(data)

outliers_iqr()

Detects outliers using IQR.

outliers_iqr(data)

Exploratory Data Analysis

eda_plot()

Universal plotting function.

Supported Plots

  • hist
  • box
  • scatter
  • line
  • bar

Example

eda_plot(
    df,
    plot_type="scatter",
    col1="Height",
    col2="Weight"
)

data_overview()

Provides a quick dataset summary.

data_overview(df)

Returns:

{
    "rows": ...,
    "columns": ...,
    "missing_values": ...,
    "duplicates": ...
}

quick_report()

Prints a quick EDA report.

quick_report(df)

Displays:

  • Rows
  • Columns
  • Missing values
  • Duplicates
  • Column names

Software Development Utilities

password_strength()

Evaluates password strength.

password_strength(
    "MyPassword123!"
)

Returns a score from 0 to 4.


validate_email()

Validates email format.

validate_email(
    "user@example.com"
)

Returns:

True

timer()

Function execution timer decorator.

@timer
def my_function():
    pass

Output:

my_function took 0.1234 sec

Developed By

Shivsamb Harkare B.Tech Instrumentation & Control Engineering COEP Technological University

Focused on:

  • Embedded Systems
  • Artificial Intelligence & Machine Learning
  • Signal Processing
  • Control Systems
  • Healthcare Technology
  • Gait Analysis & Human Activity Recognition

If you find this package useful, feel free to contribute and suggest new engineering utilities.

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

shivs_per_lib-1.1.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

shivs_per_lib-1.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file shivs_per_lib-1.1.1.tar.gz.

File metadata

  • Download URL: shivs_per_lib-1.1.1.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for shivs_per_lib-1.1.1.tar.gz
Algorithm Hash digest
SHA256 93258be81dc8d1f1f901800b4ebc9aa7bed372bc8e2d288fdcfeb76fd4d3b2b4
MD5 8682786ca44410a6a1cc85a5de0a43bc
BLAKE2b-256 7fd359a02ede3bd40c3b8497066364eaa595436b50025b6447c21c1706d9b978

See more details on using hashes here.

File details

Details for the file shivs_per_lib-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: shivs_per_lib-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for shivs_per_lib-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ad8fc4cb7deb717396fcc52f0a513268cdde185a87a664f8df68cfac006af4c
MD5 0800e539bba26d7c096f0bc2784f4d59
BLAKE2b-256 38165091d2088edfa875b846f9665e5eb893545cc85805507eb69c4e51c6d45a

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