Giter Site home page Giter Site logo

elkomplex's Introduction

๐Ÿ“š๐Ÿ”ข 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

๐Ÿ From pip

$ pip install elkomplex

๐Ÿ‘จโ€๐Ÿ’ป Development mode

$ git clone https://github.com/elkhadiy/elkomplex
$ cd elkomplex
$ python -m venv .pyenv
$ . .pyenv/bin/activate
$ pip install -e .[dev,test]
$ pytest

๐Ÿ’ป Example usage

>>> from elkomplex import i
>>> from math import e, pi
>>> 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.