Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please implement OpenMath integer_interval as Python range #29

Open
MarcoCostantini opened this issue May 12, 2020 · 0 comments · May be fixed by #34
Open

please implement OpenMath integer_interval as Python range #29

MarcoCostantini opened this issue May 12, 2020 · 0 comments · May be fixed by #34

Comments

@MarcoCostantini
Copy link

>>> 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

tkw1536 added a commit to KWARC/py-openmath that referenced this issue May 21, 2020
This issue adds translation for the range() class to the
DefaultConverter. Note that a python range(start, stop) does not include
the value of stop, whereas the 'integer_interval' symbol does. The
converter thus has to add or subtract one.

Fixes OpenMath#29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant