Skip to main content

A Python toolkit for engineering, DSP, embedded systems, machine learning, and data analysis.

Project description

shivs_per_lib

A Python utility library for Engineering, Embedded Systems, Signal Processing, Control Systems, Machine Learning, and Data Analysis.

Developed by Shivsamb Harkare, Instrumentation & Control Engineering, COEP Technological University.

shivs_per_lib was created to provide a collection of practical engineering and development utilities frequently used in academic projects, industrial applications, research work, embedded systems development, and machine learning workflows.


Installation

pip install shivs_per_lib

Quick Start

import shivs_per_lib as sp

print(
    sp.binary_to_decimal("1010")
)

print(
    sp.adc_to_voltage(
        adc_value=2048,
        bits=12,
        vref=3.3
    )
)

Function Reference


Digital Electronics

q_mc()

Performs Boolean expression minimization using the Quine-McCluskey Algorithm.

Applications

  • Logic minimization
  • Digital circuit design
  • FPGA development
  • Switching theory

Example

sp.q_mc()

The function requests:

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

and generates a simplified Boolean expression.


binary_to_gray(binary)

Converts Binary Code into Gray Code.

Parameters

Parameter Type
binary str

Example

sp.binary_to_gray("1010")

Returns

1111

binary_to_decimal(binary)

Converts a binary number to decimal.

Parameters

Parameter Type
binary str

Example

sp.binary_to_decimal("1010")

Returns

10

decimal_to_binary(number)

Converts a decimal number to binary.

Parameters

Parameter Type
number int

Example

sp.decimal_to_binary(10)

Returns

1010

Signal Processing

fft_analysis(signal, fs)

Performs Fast Fourier Transform analysis.

Parameters

Parameter Description
signal Input signal
fs Sampling frequency

Returns

frequency, magnitude

Applications

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

butter_lowpass(signal, cutoff, fs, order = 4)

Applies a Butterworth Low Pass Filter.

Parameters

Parameter Description
signal Input signal
cutoff Cutoff frequency
fs Sampling frequency
order Filter order

Returns

filtered_signal

butter_highpass(signal, cutoff, fs, order = 4)

Applies a Butterworth High Pass Filter.

Returns

filtered_signal

Applications

  • Drift removal
  • Baseline correction
  • Sensor preprocessing

moving_average(signal, window = 5)

Smooths noisy data using Moving Average Filtering.

Parameters

Parameter Description
signal Input signal
window Window size

Returns

smoothed_signal

rms(signal)

Calculates Root Mean Square value.

Returns

float

Applications

  • Signal energy estimation
  • Power calculations
  • Condition monitoring

Control Systems

pid_control(setpoint, measured, kp, ki, kd, integral, prev_error, dt)

Performs PID Controller calculations.

Parameters

Parameter Description
setpoint Desired value
measured Current value
kp Proportional gain
ki Integral gain
kd Derivative gain
integral Previous integral value
prev_error Previous error
dt Sampling interval

Returns

output, integral, error

first_order_response(K, tau, time)

Computes first-order system response.

Parameters

Parameter Description
K System gain
tau Time constant
time Time vector

Returns

response

percent_overshoot(peak, final)

Calculates percentage overshoot.

Example

sp.percent_overshoot(
    peak=120,
    final=100
)

Returns

20

steady_state_error(reference, output)

Calculates steady-state error.

Returns

error

Embedded Systems

adc_to_voltage(adc_value, bits = 12, vref = 3.3)

Converts ADC count into voltage.

Parameters

Parameter Description
adc_value ADC reading
bits ADC resolution
vref Reference voltage

Returns

float

voltage_divider(vin, r1, r2)

Calculates voltage divider output.

Returns

output_voltage

ohms_law(v = None, i = None, r = None)

Solves Ohm's Law.

Provide any two parameters and calculate the third.

Example

sp.ohms_law(
    v=12,
    r=4
)

Returns

3

pwm_duty_cycle(on_time, period)

Calculates PWM Duty Cycle percentage.

Returns

float

timer_frequency(clock_frequency, prescaler)

Calculates timer frequency.

Applications

  • AVR
  • PIC
  • STM32
  • Arduino

uart_tx_time(bytes_count, baudrate)

Calculates UART transmission time.

Returns

seconds

battery_runtime(capacity_mAh, load_current_mA)

Estimates battery runtime.

Returns

hours

crc8(data)

Computes CRC-8 checksum.

Applications

  • Embedded communication
  • Error detection
  • Packet verification

debounce(samples)

Performs digital switch debouncing.

Applications

  • Push buttons
  • Mechanical switches
  • Industrial inputs

byte_to_hex(value)

Converts a byte to hexadecimal representation.


hex_to_binary(hex_value)

Converts hexadecimal to binary.


swap_endian_16(value)

Performs 16-bit endian conversion.

Example

0x1234

becomes

0x3412

Machine Learning

normalize(data)

Performs Z-score normalization.

Returns

normalized_data

minmax_normalize(data)

Performs Min-Max normalization.

Returns

normalized_data

sliding_window(data, window_size, step)

Creates overlapping windows from sequential data.

Parameters

Parameter Description
data Input sequence
window_size Window length
step Step size

Applications

  • Time series analysis
  • Sensor analytics

quaternion_magnitude(w, x, y, z)

Calculates quaternion magnitude.

Returns

float

train_test_split(data, test_size = 0.2)

Randomly splits dataset into training and testing portions.

Returns

train_data, test_data

accuracy_score(y_true, y_pred)

Computes classification accuracy.

Returns

float

mae(y_true, y_pred)

Computes Mean Absolute Error.

Returns

float

confusion_matrix(y_true, y_pred)

Computes confusion matrix statistics.

Returns

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

Exploratory Data Analysis

missing_percentage(data)

Calculates percentage of missing values.

Returns

float

outliers_iqr(data)

Detects outliers using Interquartile Range.

Returns

list

eda_plot(df, plot_type, col1, col2 = None)

Creates common EDA visualizations.

Supported Plot Types

  • hist
  • box
  • scatter
  • line
  • bar

Example

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

data_overview(df)

Provides dataset summary.

Returns

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

quick_report(df)

Prints a quick exploratory data analysis report.

Displays:

  • Dataset size
  • Missing values
  • Duplicates
  • Column names

Software Development Utilities

password_strength(password)

Evaluates password strength.

Returns

0-4

Higher score indicates stronger password.


validate_email(email)

Validates email format.

Returns

True / False

timer

Function execution time decorator.

Example

@sp.timer
def train_model():
    pass

Output:

train_model took 0.1234 seconds

Author

Shivsamb Harkare

B.Tech Instrumentation & Control Engineering, COEP Technological University

Areas of Interest:

  • Embedded Systems
  • Signal Processing
  • Control Systems
  • Artificial Intelligence
  • Machine Learning
  • Automation

License

MIT License Copyright (c) 2025 Shivsamb Harkare

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.2.7.tar.gz (14.2 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.2.7-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shivs_per_lib-1.2.7.tar.gz
  • Upload date:
  • Size: 14.2 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.2.7.tar.gz
Algorithm Hash digest
SHA256 618dbc8a839e0ba5827e7e0efd0bea7fd3d43909407bad432907536688de3327
MD5 8f4c0896a063f4691a2f164392e5f781
BLAKE2b-256 92b2ee08dc98957e9ee516bcec2263ecc661917d1e40a435e82484070c1bd6b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: shivs_per_lib-1.2.7-py3-none-any.whl
  • Upload date:
  • Size: 11.2 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.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1e549132627023a8f8cbaa7e0ff99174d54af41d4b707d4301ca5ffeaff8afd6
MD5 be8265a00a291cb1e456e6b29c7689d5
BLAKE2b-256 6b8f15cc4222082c4b85911a0b154e7f2296cc2222522ccc1e6c631563676c45

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