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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shivs_per_lib-1.1.2.tar.gz.
File metadata
- Download URL: shivs_per_lib-1.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37bf8d259794e699d27698f11d58cf99dfec36350b4c62712c022a6696b935c7
|
|
| MD5 |
2519de1fc85dad1bb5f970f2ef4b102b
|
|
| BLAKE2b-256 |
6792ffb95724b0d3362f1feaa6b6b6735e0c110878c6edfb8a7f814a77ed656c
|
File details
Details for the file shivs_per_lib-1.1.2-py3-none-any.whl.
File metadata
- Download URL: shivs_per_lib-1.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ef1fab6fdf2246bbe626a5d0ff7d91a86700f6f2b8daead24746b1810e6abbe
|
|
| MD5 |
2c0c464fabca2e71741c21d102f181ff
|
|
| BLAKE2b-256 |
db2e1e2324fca30e2f0a7eba3f9fe527d0bd542c2b0e2290c433df08d7dbb040
|