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.3.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.3-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for shivs_per_lib-1.1.3.tar.gz
Algorithm Hash digest
SHA256 f028222d26587ace1d5811b2a76df3384dd2cea4683f912bfaf27fc081cbbf0d
MD5 e9263a40c50b3f859216a3283154c856
BLAKE2b-256 57b027cd5464777f6500c71f427468c8685f3ebbb1a25caafb7908624e8a7e88

See more details on using hashes here.

File details

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

File metadata

  • Download URL: shivs_per_lib-1.1.3-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.11.15

File hashes

Hashes for shivs_per_lib-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c0d089f1a945b28379ec64aeac89807695539367914bb877f5061378f12ebc0f
MD5 2cc5badb79ce91db64bf9e49ee69b45c
BLAKE2b-256 b933a9a5bd4b200ddb6c5cf3bfe497ae4dfad4b817611412f27511e55c2b231e

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