OpenMath / py-openmath

An OpenMath 2.0 implementation in Python
MIT License
15 stars 4 forks source link

please implement OpenMath integer_interval as Python range #29

Open MarcoCostantini opened 4 years ago

MarcoCostantini commented 4 years ago
>>> converter.to_python( decoder.decode_bytes( b"<OMA><OMS cdbase=\"http://www.openmath.org/cd\" cd=\"interval1\" name=\"integer_interval\"/><OMI>1</OMI><OMI>4</OMI></OMA>", snippet=True ) )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/openmath/convert.py", line 146, in to_python
    elem = self.to_python(omobj.elem)
  File "/usr/local/lib/python3.8/dist-packages/openmath/convert.py", line 143, in to_python
    return self._lookup_to_python(omobj.cdbase, omobj.cd, omobj.name)
  File "/usr/local/lib/python3.8/dist-packages/openmath/convert.py", line 133, in _lookup_to_python
    raise ValueError("no entry found")
ValueError: no entry found
>>> 

This should be converted to Python as range(1,5) OpenMath integer_interval is already supported by the OpenMath implementations of Gap, Macaulay2, Ruby, Yacas, and range in the standard library of Python without importing anything