summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_numeric_tower.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-101773: Optimize creation of Fractions in private methods (#101780)Sergey B Kirpichev2023-02-271-1/+1
| | | | | | This PR adds a private `Fraction._from_coprime_ints` classmethod for internal creations of `Fraction` objects, replacing the use of `_normalize=False` in the existing constructor. This speeds up creation of `Fraction` objects arising from calculations. The `_normalize` argument to the `Fraction` constructor has been removed. Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-68163: Correct conversion of Rational instances to float (GH-25619)Sergey B Kirpichev2022-09-041-0/+28
| | | | | | | * gh-68163: Correct conversion of Rational instances to float Also document that numerator/denominator properties are instances of Integral. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* Revert "bpo-26680: Incorporate is_integer in all built-in and standard ↵Raymond Hettinger2020-10-071-31/+0
| | | | | library numeric types (GH-6121)" (GH-22584) This reverts commit 58a7da9e125422323f79c4ee95ac5549989d8162.
* bpo-26680: Incorporate is_integer in all built-in and standard library ↵Robert Smallshire2020-10-011-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | numeric types (GH-6121) * bpo-26680: Adds support for int.is_integer() for compatibility with float.is_integer(). The int.is_integer() method always returns True. * bpo-26680: Adds a test to ensure that False.is_integer() and True.is_integer() are always True. * bpo-26680: Adds Real.is_integer() with a trivial implementation using conversion to int. This default implementation is intended to reduce the workload for subclass implementers. It is not robust in the presence of infinities or NaNs and may have suboptimal performance for other types. * bpo-26680: Adds Rational.is_integer which returns True if the denominator is one. This implementation assumes the Rational is represented in it's lowest form, as required by the class docstring. * bpo-26680: Adds Integral.is_integer which always returns True. * bpo-26680: Adds tests for Fraction.is_integer called as an instance method. The tests for the Rational abstract base class use an unbound method to sidestep the inability to directly instantiate Rational. These tests check that everything works correct as an instance method. * bpo-26680: Updates documentation for Real.is_integer and built-ins int and float. The call x.is_integer() is now listed in the table of operations which apply to all numeric types except complex, with a reference to the full documentation for Real.is_integer(). Mention of is_integer() has been removed from the section 'Additional Methods on Float'. The documentation for Real.is_integer() describes its purpose, and mentions that it should be overridden for performance reasons, or to handle special values like NaN. * bpo-26680: Adds Decimal.is_integer to the Python and C implementations. The C implementation of Decimal already implements and uses mpd_isinteger internally, we just expose the existing function to Python. The Python implementation uses internal conversion to integer using to_integral_value(). In both cases, the corresponding context methods are also implemented. Tests and documentation are included. * bpo-26680: Updates the ACKS file. * bpo-26680: NEWS entries for int, the numeric ABCs and Decimal. Co-authored-by: Robert Smallshire <rob@sixty-north.com>
* Issue #21741: Update 147 test modules to use test discovery.Zachary Ware2015-04-131-5/+1
| | | | | | | I have compared output between pre- and post-patch runs of these tests to make sure there's nothing missing and nothing broken, on both Windows and Linux. The only differences I found were actually tests that were previously *not* run.
* Issue #7652: Integrate the decimal floating point libmpdec library to speedStefan Krah2012-03-211-1/+1
| | | | | up the decimal module. Performance gains of the new C implementation are between 12x and 80x, depending on the application.
* #11515: Merge with 3.1.Ezio Melotti2011-03-151-1/+1
|
* Issue #8188: Comparisons between Decimal objects and other numericMark Dickinson2010-06-111-1/+56
| | | | objects (Fraction, float, complex, int) now all function as expected.
* Issue #8188: Introduce a new scheme for computing hashes of numbersMark Dickinson2010-05-231-0/+151
(instances of int, float, complex, decimal.Decimal and fractions.Fraction) that makes it easy to maintain the invariant that hash(x) == hash(y) whenever x and y have equal value.