Revert "bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121)" (GH-22584)

This reverts commit 58a7da9e12.
This commit is contained in:
Raymond Hettinger 2020-10-07 16:43:44 -07:00 committed by GitHub
parent 4f3c25043d
commit 4e0ce82058
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 24 additions and 223 deletions

View file

@ -148,7 +148,7 @@ class Real(Complex):
"""To Complex, Real adds the operations that work on real numbers.
In short, those are: a conversion to float, trunc(), divmod,
is_integer, %, <, <=, >, and >=.
%, <, <=, >, and >=.
Real also provides defaults for the derived operations.
"""
@ -242,17 +242,6 @@ class Real(Complex):
"""self <= other"""
raise NotImplementedError
def is_integer(self):
"""Return True if the Real is integral; otherwise return False.
This default implementation can be overridden in subclasses
for performance reasons or to deal with values such as NaN,
which would otherwise cause an exception to be raised.
"""
# Although __int__ is not defined at this level, the int
# constructor falls back to __trunc__, which we do have.
return self == int(self)
# Concrete implementations of Complex abstract methods.
def __complex__(self):
"""complex(self) == complex(float(self), 0)"""
@ -301,10 +290,6 @@ class Rational(Real):
"""
return self.numerator / self.denominator
def is_integer(self):
"""Return True if the Rational is integral; otherwise return False."""
return self.denominator == 1
class Integral(Rational):
"""Integral adds a conversion to int and the bit-string operations."""
@ -401,8 +386,4 @@ class Integral(Rational):
"""Integers have a denominator of 1."""
return 1
def is_integer(self):
"""Return True; all Integrals represent an integral value."""
return True
Integral.register(int)