From 0c84c63ad319bcd460d5c500146d05ea921b9d25 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Tue, 15 Oct 2019 19:32:19 +0200 Subject: [PATCH] Feat: overload pow for tokens --- mapytex/calculus/API/tokens/token.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mapytex/calculus/API/tokens/token.py b/mapytex/calculus/API/tokens/token.py index 7b62a90..b554d98 100644 --- a/mapytex/calculus/API/tokens/token.py +++ b/mapytex/calculus/API/tokens/token.py @@ -238,6 +238,28 @@ class Token(object): """ return self._operate(other, "/") + def __pow__(self, other): + """ Token powered by an other + + :example: + >>> from .number import Integer + >>> a = Integer(3) + >>> b = Integer(7) + >>> c = a ** b + >>> c + + >>> c = a ** 7 + >>> c + + >>> from .number import Decimal + >>> a = Decimal('2.3') + >>> c = a ** 2 + >>> c + + + """ + return self._operate(other, "^") + def _roperate(self, other, operation): """ Make a operation between 2 Tokens """