Skip to content

Commit e2ecd48

Browse files
committed
Release 0.2.0 with physics-aware quantities
1 parent 9a1a0d4 commit e2ecd48

21 files changed

Lines changed: 507 additions & 34 deletions

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# macOS
2+
.DS_Store
3+
build/.DS_Store
4+
5+
# Python bytecode
6+
__pycache__/
7+
*.py[cod]
8+
9+
# Build artifacts
10+
/build/
11+
/dist/
12+
/*.egg-info/
13+
14+
# Virtual environments
15+
.venv/
16+
venv/

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Voltops
22

3-
**Voltops** is a Python library built for electronics and signal processing enthusiasts. Whether you're an engineer, student, or hobbyist, this package offers intuitive functions for working with electrical formulas and analyzing signals with ease.
3+
**Voltops** is a Python library built for electronics and signal processing enthusiasts. Whether you're an engineer, student, or hobbyist, this package offers intuitive functions for working with electrical formulas and analyzing signals with ease. Every function is **physics-aware**—values carry metadata (DC/AC, RMS/peak, phase, frequency) so you catch mistakes before they propagate.
44

55
---
66

@@ -21,11 +21,11 @@ from voltops.formulas.basic import BasicFormulas
2121

2222
# Calculate voltage using Ohm's Law: V = I * R
2323
voltage = BasicFormulas.ohms_law(current=2, resistance=5)
24-
print(f"Voltage: {voltage} V") # Output: Voltage: 10 V
24+
print(f"Voltage: {voltage.value} V (kind={voltage.metadata.kind})")
2525

2626
# Calculate power: P = V * I
27-
power = BasicFormulas.power(voltage=10, current=2)
28-
print(f"Power: {power} W") # Output: Power: 20 W
27+
power = BasicFormulas.power(voltage=voltage, current=2)
28+
print(f"Power: {power.value} W")
2929
```
3030

3131
### Frequency Spectrum Analysis
@@ -58,10 +58,13 @@ filtered_signal = Filters.low_pass_filter(signal, cutoff=15, sampling_rate=1000)
5858

5959
## Features
6060

61-
- **Electronic Formulas**: Ohm's Law, power, and more.
61+
- **Physics-aware quantities**: Voltage, Current, Resistance/Impedance, Power, Frequency, and Phase objects with waveform metadata.
62+
- **Electronic Formulas**: Ohm's Law, power, and more—now returning safe quantity objects.
6263
- **Signal Processing**: FFT, DFT, filtering, and spectral analysis.
6364
- **Extensible API**: Easy-to-use, modular design for seamless integration.
6465

66+
Learn more about the design direction in [`docs/philosophy.md`](docs/philosophy.md).
67+
6568

6669
## Contributing
6770

@@ -74,7 +77,7 @@ If you'd like to report a bug, request a feature, or contribute code, feel free
7477
This library is actively developed and maintained by **Madhur Thareja**.
7578

7679

77-
## 📄 License
80+
## License
7881

7982
Licensed under the [MIT License](https://opensource.org/licenses/MIT).
8083
Feel free to use, modify, and distribute this library.
8.32 KB
Binary file not shown.

dist/voltops-0.2.0.tar.gz

8.44 KB
Binary file not shown.

docs/philosophy.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# VoltOps Core Philosophy
2+
3+
VoltOps delivers **physics-aware computation for everyday electronics and signal-analysis workflows**. Each public API corresponds to a concept that practicing engineers recognize—Ohm's Law, impedance, FFT-based measurement, and so on. Rather than replicating generic math helpers, VoltOps focuses on wiring realistic metadata, guardrails, and educational context into every computation.
4+
5+
---
6+
7+
## Guiding Assumptions
8+
9+
- **Linear, time-invariant, lumped elements** unless explicitly stated.
10+
- **Steady-state analysis** is the default; transient behavior must be modeled consciously.
11+
- **Closed-form expressions first**. Numerical solvers and optimizers stay in delegated libraries (e.g., SciPy) until they can be wrapped with clear physics-aware semantics.
12+
- **Quantities, not scalars**. VoltOps manipulates `Voltage`, `Current`, `Power`, etc., keeping track of waveform kind (DC, AC RMS, AC peak), phase references, and carrier frequency.
13+
14+
## Non‑Goals (for now)
15+
16+
Reinforcing explicit "no" statements builds trust:
17+
18+
- VoltOps is **not** a SPICE replacement or a general-purpose circuit simulator.
19+
- **No real-time execution guarantees**—runtime safety belongs to your embedded toolchain.
20+
- **No nonlinear semiconductor device physics**. Analytical helpers for BJTs/FETs may arrive later, but they will remain closed-form.
21+
- **No blind duplication of SciPy/NumPy** utilities. We wrap them only when physics-aware metadata adds value.
22+
23+
## Design Principles
24+
25+
1. **Quantities over scalars** – Type-safe values that guard against invalid operations and attach waveform metadata everywhere.
26+
2. **Physical invariants as tests** – Unit tests assert conservation laws, scaling behavior, and dimensional consistency instead of memorizing golden numbers.
27+
3. **Layered architecture** – Packages are separated into `core/` (metadata + quantities), `formulas/`, `signal_processing/`, and future `circuits/` or `numeric/` layers. Lower layers never depend on higher ones.
28+
4. **Context-rich results** – APIs return annotated objects. Even FFT helpers yield spectra with sampling metadata rather than naked arrays.
29+
5. **Delegation with intent** – Expensive numerical kernels continue to live in SciPy/NumPy; VoltOps focuses on keeping the surrounding context faithful to the underlying physics.
30+
31+
## Roadmap Snapshot
32+
33+
| Theme | Why it matters | Current Status |
34+
| --- | --- | --- |
35+
| Quantity primitives | Enforce metadata, catch misuse early | (`voltage`, `current`, `resistance`, etc.) |
36+
| Circuit abstractions | Series/parallel, dividers, equivalents | planned |
37+
| Measurement helpers | ADC quantization, SNR, aliasing guards | planned |
38+
| Signal-aware DSP | FFTs that return annotated spectra | foundational transforms |
39+
| Symbolic hooks | Bridge SymPy for derivations | future exploration |
40+
41+
## How This Shapes Implementation
42+
43+
- **APIs describe intent**: instead of `voltage = i * r`, users call `BasicFormulas.ohms_law(current=i, resistance=r)` and receive a `Voltage` object tied to the originating metadata.
44+
- **Docs teach, not just list**: each recipe explains the physical context, common pitfalls, and how VoltOps keeps track of assumptions.
45+
- **Architecture anticipates acceleration**: should we swap in C++ kernels later, the Python-facing API remains unchanged because all metadata plumbing lives in `core/`.
46+
47+
## Delegations
48+
49+
| Capability | Preferred Library |
50+
| --- | --- |
51+
| Large-scale linear algebra | NumPy / SciPy |
52+
| Nonlinear solvers & optimizers | SciPy |
53+
| Symbolic manipulation | SymPy (optional future layer) |
54+
| Plotting / visualization | Matplotlib, Plotly, etc. (kept outside VoltOps) |
55+
56+
---
57+
58+
VoltOps succeeds when it saves engineers from re-deriving the same relationships, documents the assumptions behind every helper, and keeps metadata honest from input to output. Depth over breadth, physics over convenience, meaning over speed.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="voltops",
5-
version="0.1.1",
5+
version="0.2.0",
66
author="Madhur Thareja",
77
author_email="madhurthareja1105@gmail.com",
88
description="A Python library for electronic formulas and signal processing",
-18.7 KB
Binary file not shown.
-18.7 KB
Binary file not shown.

tests/test_voltops.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
import pytest
22
import numpy as np
33
from voltops.formulas.basic import BasicFormulas
4+
from voltops.core.quantities import Voltage, Current, Resistance, Power, SignalMetadata, SignalKind
45
from voltops.signal_processing.filters import Filters
56
from voltops.signal_processing.transforms import Transforms
67

78
def test_ohms_law():
8-
assert BasicFormulas.ohms_law(current=2, resistance=5) == 10
9-
assert BasicFormulas.ohms_law(voltage=10, resistance=5) == 2
10-
assert BasicFormulas.ohms_law(voltage=10, current=2) == 5
9+
voltage = BasicFormulas.ohms_law(current=2, resistance=5)
10+
assert isinstance(voltage, Voltage)
11+
assert voltage.value == pytest.approx(10)
12+
13+
current = BasicFormulas.ohms_law(voltage=10, resistance=5)
14+
assert isinstance(current, Current)
15+
assert current.value == pytest.approx(2)
16+
17+
resistance = BasicFormulas.ohms_law(voltage=10, current=2)
18+
assert isinstance(resistance, Resistance)
19+
assert resistance.value == pytest.approx(5)
1120

1221
def test_power():
13-
assert BasicFormulas.power(voltage=10, current=2) == 20
22+
power = BasicFormulas.power(voltage=10, current=2)
23+
assert isinstance(power, Power)
24+
assert power.value == pytest.approx(20)
25+
26+
ac_metadata = SignalMetadata(kind=SignalKind.AC_RMS, frequency_hz=60, phase_deg=0)
27+
voltage = Voltage(120, metadata=ac_metadata)
28+
current = Current(10, metadata=ac_metadata)
29+
ac_power = BasicFormulas.power(voltage=voltage, current=current)
30+
assert ac_power.metadata.kind is SignalKind.AC_RMS
31+
32+
33+
def test_power_metadata_mismatch():
34+
meta_a = SignalMetadata(kind=SignalKind.AC_RMS, frequency_hz=50, phase_deg=0)
35+
meta_b = SignalMetadata(kind=SignalKind.AC_RMS, frequency_hz=60, phase_deg=0)
36+
voltage = Voltage(10, metadata=meta_a)
37+
current = Current(1, metadata=meta_b)
38+
with pytest.raises(ValueError):
39+
BasicFormulas.power(voltage=voltage, current=current)
1440

1541
def test_frequency_spectrum():
1642
t = np.linspace(0, 1, 1000, endpoint=False)

voltops.egg-info/PKG-INFO

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.4
22
Name: voltops
3-
Version: 0.1.1
3+
Version: 0.2.0
44
Summary: A Python library for electronic formulas and signal processing
55
Home-page: https://github.com/madhurthareja/voltops
66
Author: Madhur Thareja
@@ -24,7 +24,7 @@ Dynamic: summary
2424

2525
# Voltops
2626

27-
**Voltops** is a Python library built for electronics and signal processing enthusiasts. Whether you're an engineer, student, or hobbyist, this package offers intuitive functions for working with electrical formulas and analyzing signals with ease.
27+
**Voltops** is a Python library built for electronics and signal processing enthusiasts. Whether you're an engineer, student, or hobbyist, this package offers intuitive functions for working with electrical formulas and analyzing signals with ease. Every function is **physics-aware**—values carry metadata (DC/AC, RMS/peak, phase, frequency) so you catch mistakes before they propagate.
2828

2929
---
3030

@@ -45,11 +45,11 @@ from voltops.formulas.basic import BasicFormulas
4545

4646
# Calculate voltage using Ohm's Law: V = I * R
4747
voltage = BasicFormulas.ohms_law(current=2, resistance=5)
48-
print(f"Voltage: {voltage} V") # Output: Voltage: 10 V
48+
print(f"Voltage: {voltage.value} V (kind={voltage.metadata.kind})")
4949

5050
# Calculate power: P = V * I
51-
power = BasicFormulas.power(voltage=10, current=2)
52-
print(f"Power: {power} W") # Output: Power: 20 W
51+
power = BasicFormulas.power(voltage=voltage, current=2)
52+
print(f"Power: {power.value} W")
5353
```
5454

5555
### Frequency Spectrum Analysis
@@ -82,10 +82,13 @@ filtered_signal = Filters.low_pass_filter(signal, cutoff=15, sampling_rate=1000)
8282

8383
## Features
8484

85-
- **Electronic Formulas**: Ohm's Law, power, and more.
85+
- **Physics-aware quantities**: Voltage, Current, Resistance/Impedance, Power, Frequency, and Phase objects with waveform metadata.
86+
- **Electronic Formulas**: Ohm's Law, power, and more—now returning safe quantity objects.
8687
- **Signal Processing**: FFT, DFT, filtering, and spectral analysis.
8788
- **Extensible API**: Easy-to-use, modular design for seamless integration.
8889

90+
Learn more about the design direction in [`docs/philosophy.md`](docs/philosophy.md).
91+
8992

9093
## Contributing
9194

@@ -98,7 +101,7 @@ If you'd like to report a bug, request a feature, or contribute code, feel free
98101
This library is actively developed and maintained by **Madhur Thareja**.
99102

100103

101-
## 📄 License
104+
## License
102105

103106
Licensed under the [MIT License](https://opensource.org/licenses/MIT).
104107
Feel free to use, modify, and distribute this library.

0 commit comments

Comments
 (0)