Refactor code in directories + add doc strings

This commit is contained in:
Clément Barthélemy 2024-02-20 00:01:55 +01:00
parent 0d9a636da6
commit 77c8973eb7
2 changed files with 23 additions and 3 deletions

View file

@ -3,6 +3,12 @@ from typing import *
def gcd(a, b):
"""
Greatest common divisor
work with any object that support modulo and comparison (contrary to math.gcd)
used in type : Fraction
"""
if b > a:
return gcd(b, a)

View file

@ -1,5 +1,5 @@
from __future__ import annotations
# from expr import Expr
class Symbols:
@ -18,6 +18,22 @@ class Symbols:
def __str__(self):
return self.name
def __add__(self, other):
from python_symb.Expressions.expr import Expr
return Expr('+', [self, other])
def __radd__(self, other):
from python_symb.Expressions.expr import Expr
return Expr('+', [other, self])
def __mul__(self, other):
from python_symb.Expressions.expr import Expr
return Expr('*', [self, other])
def __rmul__(self, other):
from python_symb.Expressions.expr import Expr
return Expr('*', [other, self])
class Var(Symbols):
"""
@ -29,6 +45,4 @@ class Var(Symbols):
super().__init__(name)
self.__class__.instances.append(self)
"""def __add__(self, other) -> Expr:
return Expr('+', [self, other])"""