Ask Your Question

Unable to convert string to rational when plus sign is added

asked 2020-01-13 23:24:53 +0200

Jose Brox gravatar image

updated 2020-01-13 23:26:25 +0200

This looks like a bug. The code


gives the exception

TypeError: unable to convert '+1' to a rational

This happens with any positive rational, not just 1.

Also, this does not happen with neither




Is this actually a bug? If it is, can someone investigate it and write a trac ticket? I'm quite new to Sagemath and Python and quite unskilled yet to do it properly. Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-01-14 05:46:40 +0200

As far as I can tell, Sage uses gmp( to construct its rational numbers, and the gmp function mpq_set_strdoesn't handle the leading plus sign. In any case, I would call it a lack of a feature rather than a bug. I've opened

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-01-13 23:24:53 +0200

Seen: 611 times

Last updated: Jan 14 '20