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
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.2.5.tar.gz.
File metadata
- Download URL: shivs_per_lib-1.2.5.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2651127b4bcc7aa5e9abfb8bdc4cc3817d91c692ef2c904b4c2c1056b715eefc
|
|
| MD5 |
4d8b20b788bdd332f092fe876163c175
|
|
| BLAKE2b-256 |
357b717f58bb8ba86e76ce91ea12aede7bc807023fb9c14fb915e861a6c8335c
|
File details
Details for the file shivs_per_lib-1.2.5-py3-none-any.whl.
File metadata
- Download URL: shivs_per_lib-1.2.5-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a45e635f7b1194d6ed38a56bc9c4dd6e39e5eeeefadf72da4478676e447b8645
|
|
| MD5 |
68024f34fe064e9467673b2f5f39d815
|
|
| BLAKE2b-256 |
be0ca899572a3e307df34a07ed26080463a33dd1351428fb6af41402ef3e2e22
|