File tree 1 file changed +10
-8
lines changed
1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -188,8 +188,8 @@ cdef class Fraction:
188
188
189
189
elif isinstance (numerator, Decimal):
190
190
value = Fraction.from_decimal(numerator)
191
- self ._numerator = value._numerator
192
- self ._denominator = value._denominator
191
+ self ._numerator = ( < Fraction > value) ._numerator
192
+ self ._denominator = ( < Fraction > value) ._denominator
193
193
return
194
194
195
195
else :
@@ -429,6 +429,8 @@ cdef class Fraction:
429
429
430
430
def __pos__ (a ):
431
431
""" +a: Coerces a subclass instance to Fraction"""
432
+ if type (a) is Fraction:
433
+ return a
432
434
return Fraction(a._numerator, a._denominator, _normalize = False )
433
435
434
436
def __neg__ (a ):
@@ -494,15 +496,15 @@ cdef class Fraction:
494
496
""" complex(self) == complex(float(self), 0)"""
495
497
return complex (float (self ))
496
498
497
- @property
498
- def real (self ):
499
+ property real :
499
500
""" Real numbers are their real component."""
500
- return + self
501
+ def __get__ (self ):
502
+ return + self
501
503
502
- @property
503
- def imag (self ):
504
+ property imag :
504
505
""" Real numbers have no imaginary component."""
505
- return 0
506
+ def __get__ (self ):
507
+ return 0
506
508
507
509
def conjugate (self ):
508
510
""" Conjugate is a no-op for Reals."""
You can’t perform that action at this time.
0 commit comments