Ask Your Question

Unable to convert string to rational when plus sign is added

asked 2020-01-13 16:24:53 -0500

Jose Brox gravatar image

updated 2020-01-13 16:26:25 -0500

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-13 22:46:40 -0500

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 16:24:53 -0500

Seen: 49 times

Last updated: Jan 13