MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __eq__

Method __eq__

tools/python-3.11.9-amd64/Lib/fractions.py:678–697  ·  view source on GitHub ↗

a == b

(a, b)

Source from the content-addressed store, hash-verified

676 return -2 if result == -1 else result
677
678 def __eq__(a, b):
679 """a == b"""
680 if type(b) is int:
681 return a._numerator == b and a._denominator == 1
682 if isinstance(b, numbers.Rational):
683 return (a._numerator == b.numerator and
684 a._denominator == b.denominator)
685 if isinstance(b, numbers.Complex) and b.imag == 0:
686 b = b.real
687 if isinstance(b, float):
688 if math.isnan(b) or math.isinf(b):
689 # comparisons with an infinity or nan should behave in
690 # the same way for any finite a, so treat a as zero.
691 return 0.0 == b
692 else:
693 return a == a.from_float(b)
694 else:
695 # Since a doesn't know how to compare with b, let's give b
696 # a chance to compare itself with a.
697 return NotImplemented
698
699 def _richcmp(self, other, op):
700 """Helper for comparison operators, for internal use only.

Callers

nothing calls this directly

Calls 2

typeClass · 0.50
from_floatMethod · 0.45

Tested by

no test coverage detected