Toy implementation of a complex datatype
Project description
📚🔢 Toy implementation of a complex number data type in Python
This module is a basic implementation of complex numbers in Python. The goal is to demonstrate basic know-how in Python packaging, project managment, documentation and testing.
This package is not in any way, shape or form suitable for production!
💽 Install
👨💻 Development mode
$ git clone https://github.com/elkhadiy/elkomplex
$ cd elkomplex
$ python -m venv .pyenv
$ . .pyenv/bin/activate
$ pip install -e .[dev,test]
💻 Example usage
>>> from elkomplex import i
>>> from math import e
>>> str(e**(i*pi))
'-1.00 + 0.00 i'
Intuitive interface
>>> from elkomplex import i
>>> f"{i}"
'0 + 1 i'
>>> f"{i * i:0.2f}"
'-1.00 + 0.00 i'
>>> f"{2 + 3 * i}"
'2.0 + 3.0 i'
>>> f"{(2 + 3 * i) * (4 + 5 * i):0.2f}"
'-7.00 + 22.00 i'
Create a complex number from real and imaginary parts
>>> from elkomplex import Komplex
>>> Komplex.from_cartesian(2, 3)
Komplex(re=2.00, im=3.00, r=3.61, th=0.98)
Create a complex number from polar coordinates
>>> from math import pi
>>> Komplex.from_polar(1, pi / 4)
Komplex(re=0.71, im=0.71, r=1.00, th=0.79)
📋 ToDo
- ✅ Package squeleton
- ✅ Base complex class
- ✅ Basic constructors
- ✅ Formatting and printing
- ✅ Pytest framework
- 🚧 Basic Arithmetic methods
- ✅ Addition
- ✅ Substraction
- ✅ Multiplication
- ✅ Division
- ✅ Comparison
- ✅ Negation
- ✅ Module
- ✅ Inversion
- ✅ Conjugate
- 🚧 Power
- ⬜ Advanced Math functions
- ⬜ Exponent
- ⬜ Sqrt
- ⬜ Logarithm
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
elkomplex-0.1.2.tar.gz
(6.0 kB
view details)
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 elkomplex-0.1.2.tar.gz.
File metadata
- Download URL: elkomplex-0.1.2.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9a1a5bc7db3f81187245d20047d956340ea363ebb1493cf7dfccfc7b5c74d3e
|
|
| MD5 |
96cf015999a0f0d27680b954ae907fff
|
|
| BLAKE2b-256 |
ebf9c1030e051e92a66bd3a9ca77bd771233df236ac9dd46b29df25af37ee325
|
File details
Details for the file elkomplex-0.1.2-py3-none-any.whl.
File metadata
- Download URL: elkomplex-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1b370d7ff13f345ed63152b2de3077687ecc2725a7b72c74dccccc96a92aa20
|
|
| MD5 |
8c8a1160567746cee6fe8a52b685088c
|
|
| BLAKE2b-256 |
02aca07c0ddc7ada7903e425cb211aa9684162669ae28b739736d53372cda8b3
|