Metadata-Version: 2.4
Name: shivs_per_lib
Version: 1.2.3
Summary: A personal utility package by Shivsamb Harkare.
Author: Shivsamb Mangalkumar Harkare
Author-email: shivsamb1984@gmail.com
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: pandas
Requires-Dist: matplotlib
Requires-Dist: tensorflow
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 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

```bash
pip install shivs_per_lib
```

---

# Quick Start

```python
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

---

# Basic Utilities

## str_to_int(given_list)

Converts a list of numeric strings into integers.

### Parameters

| Parameter  | Type | Description                     |
| ---------- | ---- | ------------------------------- |
| given_list | list | List containing numeric strings |

### Example

```python
sp.str_to_int(
    ["1","2","3"]
)
```

### Returns

```python
[1,2,3]
```

---

## int_to_str(given_list)

Converts a list of integers into strings.

### Parameters

| Parameter  | Type |
| ---------- | ---- |
| given_list | list |

### Example

```python
sp.int_to_str(
    [1,2,3]
)
```

### Returns

```python
["1","2","3"]
```

---

# Digital Electronics

## q_mc()

Performs Boolean expression minimization using the Quine-McCluskey Algorithm.

### Applications

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

### Example

```python
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

```python
sp.binary_to_gray("1010")
```

### Returns

```python
1111
```

---

## binary_to_decimal(binary)

Converts a binary number to decimal.

### Parameters

| Parameter | Type |
| --------- | ---- |
| binary    | str  |

### Example

```python
sp.binary_to_decimal("1010")
```

### Returns

```python
10
```

---

## decimal_to_binary(number)

Converts a decimal number to binary.

### Parameters

| Parameter | Type |
| --------- | ---- |
| number    | int  |

### Example

```python
sp.decimal_to_binary(10)
```

### Returns

```python
1010
```

---

# Signal Processing

## fft_analysis(signal, fs)

Performs Fast Fourier Transform analysis.

### Parameters

| Parameter | Description        |
| --------- | ------------------ |
| signal    | Input signal       |
| fs        | Sampling frequency |

### Returns

```python
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

```python
filtered_signal
```

---

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

Applies a Butterworth High Pass Filter.

### Returns

```python
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

```python
smoothed_signal
```

---

## rms(signal)

Calculates Root Mean Square value.

### Returns

```python
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

```python
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

```python
response
```

---

## percent_overshoot(peak, final)

Calculates percentage overshoot.

### Example

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

### Returns

```python
20
```

---

## steady_state_error(reference, output)

Calculates steady-state error.

### Returns

```python
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

```python
float
```

---

## voltage_divider(vin, r1, r2)

Calculates voltage divider output.

### Returns

```python
output_voltage
```

---

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

Solves Ohm's Law.

Provide any two parameters and calculate the third.

### Example

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

### Returns

```python
3
```

---

## pwm_duty_cycle(on_time, period)

Calculates PWM Duty Cycle percentage.

### Returns

```python
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

```python
seconds
```

---

## battery_runtime(capacity_mAh, load_current_mA)

Estimates battery runtime.

### Returns

```python
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

```python
0x1234
```

becomes

```python
0x3412
```

---

# Machine Learning

## normalize(data)

Performs Z-score normalization.

### Returns

```python
normalized_data
```

---

## minmax_normalize(data)

Performs Min-Max normalization.

### Returns

```python
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

```python
float
```

---

## train_test_split(data, test_size=0.2)

Randomly splits dataset into training and testing portions.

### Returns

```python
train_data, test_data
```

---

## accuracy_score(y_true, y_pred)

Computes classification accuracy.

### Returns

```python
float
```

---

## mae(y_true, y_pred)

Computes Mean Absolute Error.

### Returns

```python
float
```

---

## confusion_matrix(y_true, y_pred)

Computes confusion matrix statistics.

### Returns

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

---

# Exploratory Data Analysis

## missing_percentage(data)

Calculates percentage of missing values.

### Returns

```python
float
```

---

## outliers_iqr(data)

Detects outliers using Interquartile Range.

### Returns

```python
list
```

---

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

Creates common EDA visualizations.

### Supported Plot Types

* hist
* box
* scatter
* line
* bar

### Example

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

---

## data_overview(df)

Provides dataset summary.

### Returns

```python
{
    "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

```python
0-4
```

Higher score indicates stronger password.

---

## validate_email(email)

Validates email format.

### Returns

```python
True / False
```

---

## timer

Function execution time decorator.

### Example

```python
@sp.timer
def train_model():
    pass
```

Output:

```python
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
 

---

# License

MIT License
Copyright (c) 2025 Shivsamb Harkare
