Feat: tokenify for everything!
This commit is contained in:
@@ -91,6 +91,12 @@ class MOnumber(Atom):
|
||||
>>> MOnumber(Decimal("-23.3"))
|
||||
<MOnumber - 23.3>
|
||||
|
||||
Or directly passe a decimal string
|
||||
>>> MOnumber("23.3")
|
||||
<MOnumber 23.3>
|
||||
>>> MOnumber("-23.3")
|
||||
<MOnumber - 23.3>
|
||||
|
||||
MOnumber initialisation is idempotent
|
||||
|
||||
>>> a = MOnumber(23)
|
||||
@@ -100,7 +106,7 @@ class MOnumber(Atom):
|
||||
>>> MOnumber("a")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
mapytex.calculus.core.MO.exceptions.MOError: ('The value of an MOnumber need to be a int, a float or a Decimal', "(got <class 'str'>)")
|
||||
mapytex.calculus.core.MO.exceptions.MOError: ('The value of an MOnumber need to be a int, a float, a Decimal or a decimal string', "(got <class 'str'>)")
|
||||
|
||||
Atoms specific property and methods
|
||||
|
||||
@@ -122,10 +128,15 @@ class MOnumber(Atom):
|
||||
elif isinstance(value, float):
|
||||
Atom.__init__(self, Decimal(value))
|
||||
else:
|
||||
raise MOError(
|
||||
"The value of an MOnumber need to be a int, a float or a Decimal",
|
||||
f"(got {type(value)})",
|
||||
)
|
||||
try:
|
||||
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))
|
||||
|
||||
self._signature = "scalar"
|
||||
|
||||
|
Reference in New Issue
Block a user