Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python's Fraction Incompatibility ?

Hi

Sagemath doesn't seem to recognize Fraction from the standard module fractions :

$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.0, Release Date: 2017-07-21                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: from fractions import Fraction 
sage: Fraction
<class 'fractions.Fraction'>
sage: Fraction(2,3)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-9755b3988eff> in <module>()
----> 1 Fraction(Integer(2),Integer(3))

/sage8.0/SageMath/local/lib/python2.7/fractions.pyc in __new__(cls, numerator, denominator) 152 isinstance(denominator, Rational)): 153 numerator, denominator = ( --> 154 numerator.numerator * denominator.denominator, 155 denominator.numerator * numerator.denominator 156 )

TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'builtin_function_or_method'

Any workaround ?

Python's Fraction Incompatibility ?

Hi

Sagemath doesn't seem to recognize Fraction from the standard module fractions :

$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.0, Release Date: 2017-07-21                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: from fractions import Fraction 
sage: Fraction
<class 'fractions.Fraction'>
sage: Fraction(2,3)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-9755b3988eff> in <module>()
----> 1 Fraction(Integer(2),Integer(3))

/sage8.0/SageMath/local/lib/python2.7/fractions.pyc in __new__(cls, numerator, denominator) 152 isinstance(denominator, Rational)): 153 numerator, denominator = ( --> 154 numerator.numerator * denominator.denominator, 155 denominator.numerator * numerator.denominator 156 )

)

TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'builtin_function_or_method'

Any workaround ?

Python's Fraction Incompatibility ?

Hi

Sagemath doesn't seem to recognize Fraction from the standard module fractions :

$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.0, Release Date: 2017-07-21                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: from fractions import Fraction 
sage: Fraction
<class 'fractions.Fraction'>
sage: Fraction(2,3)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-9755b3988eff> in <module>()
----> 1 Fraction(Integer(2),Integer(3))

 /sage8.0/SageMath/local/lib/python2.7/fractions.pyc in __new__(cls, numerator, denominator)
    152             isinstance(denominator, Rational)):
    153             numerator, denominator = (
--> 154                 numerator.numerator * denominator.denominator,
    155                 denominator.numerator * numerator.denominator
    156                 )

TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'builtin_function_or_method'

Any workaround ?