From b93f34bc38e7b5adde997650615ed47b41bd3046 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 17 Jul 2019 09:53:03 +0200 Subject: [PATCH] Feat: MOnumber creating with a integer string --- mapytex/calculus/core/MO/atoms.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mapytex/calculus/core/MO/atoms.py b/mapytex/calculus/core/MO/atoms.py index 67919f1..897cfac 100644 --- a/mapytex/calculus/core/MO/atoms.py +++ b/mapytex/calculus/core/MO/atoms.py @@ -132,14 +132,17 @@ class MOnumber(Atom): Atom.__init__(self, value) else: try: - float(value) + v = float(value) except (ValueError, TypeError): raise MOError( "The value of an MOnumber need to be a int, a float, a Decimal or a decimal string", f"(got {type(value)})", ) else: - Atom.__init__(self, Decimal(value)) + if int(v) == v: + Atom.__init__(self, int(v)) + else: + Atom.__init__(self, Decimal(value)) self._signature = "scalar"