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

the mechanism for registering converters didn't work for me #27

Open
MarcoCostantini opened this issue May 12, 2020 · 1 comment
Open

Comments

@MarcoCostantini
Copy link

I tried the example at the bottom of page https://github.com/OpenMath/py-openmath: I tried to copy and paste each line, but it didn't work for me:

Finally, this class contains a mechanism for registering converters.
$ python3
Python 3.8.2 (default, Mar 13 2020, 10:14:16)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from fractions import Fraction
>>> from openmath import openmath as om
>>> from openmath.convert import DefaultConverter as converter
>>> def to_om_rat(obj):
...     return om.OMApplication(om.OMSymbol('rational', cd='nums1'),
...             list(map(converter.to_openmath, [obj.numerator, obj.denominator])))
...
>>> def to_py_rat(obj):
...     return Fraction(converter.to_python(obj.arguments[0]), converter.to_python(obj.arguments[1]))
...
>>> converter.register(Fraction, to_om_rat, 'nums1', 'rational', to_py_rat)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'BasicPythonConverter' object has no attribute 'register'
>>>

@defeo
Copy link
Collaborator

defeo commented May 15, 2020

Thanks for filing these issues! I have literally zero bandwidth for this, at the moment, but if you'd like to submit a pull request, I'd be happy to review it.

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

No branches or pull requests

2 participants