summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_float.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-53203: Improve tests for strptime() (GH-125090)Serhiy Storchaka2024-10-081-1/+1
| | | | | | | | | | Run them with different locales and different date and time. Add the @run_with_locales() decorator to run the test with multiple locales. Improve the run_with_locale() context manager/decorator -- it now catches only expected exceptions and reports the test as skipped if no appropriate locale is available.
* gh-123811: test that round() can return signed zero (#123829)Sergey B Kirpichev2024-09-111-5/+5
|
* gh-121039: add Floats/ComplexesAreIdenticalMixin to test.support.testcase ↵Sergey B Kirpichev2024-09-081-9/+3
| | | | (GH-121071)
* gh-84978: Add float.from_number() and complex.from_number() (GH-26827)Serhiy Storchaka2024-07-151-28/+61
| | | | | | They are alternate constructors which only accept numbers (including objects with special methods __float__, __complex__ and __index__), but not strings.
* gh-120080: Mark test_round_with_none_arg_direct_call as cpython_only (#120328)Kirill Podoprigora2024-06-111-0/+1
|
* gh-120080: Accept ``None`` as a valid argument for direct call of the ↵Kirill Podoprigora2024-06-071-0/+6
| | | | | ``int.__round__`` (#120088) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-111765: Move old PyFloat_* tests to Lib/test/test_capi/test_float.py ↵Sergey B Kirpichev2023-11-071-65/+0
| | | | (GH-111766)
* gh-108303: Move all math files to `Lib/test/mathdata/` (#109512)Nikita Sobolev2023-09-211-1/+2
|
* gh-109546: Add more tests for formatting floats and fractions (GH-109548)Serhiy Storchaka2023-09-191-2/+7
|
* gh-104263: Rely on Py_NAN and introduce Py_INFINITY (GH-104202)Sebastian Berg2023-05-101-4/+1
| | | | | | | | | | This PR removes `_Py_dg_stdnan` and `_Py_dg_infinity` in favour of using the standard `NAN` and `INFINITY` macros provided by C99. This change has the side-effect of fixing a bug on MIPS where the hard-coded value used by `_Py_dg_stdnan` gave a signalling NaN rather than a quiet NaN. --------- Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-95605: Fix `float(s)` error message when `s` contains only whitespace ↵Mark Dickinson2022-08-101-0/+4
| | | | | (GH-95665) This PR fixes the error message from float(s) in the case where s contains only whitespace.
* GH-94808: Cover handling non-finite numbers from round when ndigits is ↵Michael Droettboom2022-07-141-0/+5
| | | | provided (GH-94860)
* gh-84623: Remove unused imports in tests (#93772)Victor Stinner2022-06-131-1/+0
|
* bpo-45995: add "z" format specifer to coerce negative 0 to zero (GH-30049)John Belmonte2022-04-111-12/+10
| | | | | | | | Add "z" format specifier to coerce negative 0 to zero. See https://github.com/python/cpython/issues/90153 (originally https://bugs.python.org/issue45995) for discussion. This covers `str.format()` and f-strings. Old-style string interpolation is not supported. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-46906: Add PyFloat_Pack8() to the C API (GH-31657)Victor Stinner2022-03-111-1/+73
| | | | | | | | | | | | | | | | | | | | | | Add new functions to pack and unpack C double (serialize and deserialize): * PyFloat_Pack2(), PyFloat_Pack4(), PyFloat_Pack8() * PyFloat_Unpack2(), PyFloat_Unpack4(), PyFloat_Unpack8() Document these functions and add unit tests. Rename private functions and move them from the internal C API to the public C API: * _PyFloat_Pack2() => PyFloat_Pack2() * _PyFloat_Pack4() => PyFloat_Pack4() * _PyFloat_Pack8() => PyFloat_Pack8() * _PyFloat_Unpack2() => PyFloat_Unpack2() * _PyFloat_Unpack4() => PyFloat_Unpack4() * _PyFloat_Unpack8() => PyFloat_Unpack8() Replace the "unsigned char*" type with "char*" which is more common and easy to use.
* bpo-46852: Restore test_getformat() test (GH-31601)Victor Stinner2022-02-271-3/+11
|
* bpo-46852: Remove the float.__set_format__() method (GH-31585)Victor Stinner2022-02-251-70/+0
| | | | | | Remove the undocumented private float.__set_format__() method, previously known as float.__set_format__() in Python 3.7. Its docstring said: "You probably don't want to use this function. It exists mainly to be used in Python's test suite."
* bpo-45668: Fix PGO tests without test extensions (GH-29315)Christian Heimes2021-11-011-1/+2
|
* bpo-43413: Fix handling keyword arguments in subclasses of some buitin ↵Serhiy Storchaka2021-09-121-0/+27
| | | | | | | | classes (GH-26456) * Constructors of subclasses of some buitin classes (e.g. tuple, list, frozenset) no longer accept arbitrary keyword arguments. * Subclass of set can now define a __new__() method with additional keyword parameters without overriding also __init__().
* bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834)Mark Dickinson2021-08-201-0/+14
|
* bpo-28395: Remove unnecessary semicolons in tests (GH-26868)Dong-hee Na2021-06-231-4/+4
|
* bpo-43475: Fix the Python implementation of hash of Decimal NaN (GH-26679)Serhiy Storchaka2021-06-121-0/+19
|
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25171)Inada Naoki2021-04-041-2/+2
| | | | | | | | | | | * Fix test_float * Fix _osx_support * Fix test_fstring * Fix test_gc * Fix test_gzip * Fix test_hashlib * Fix unrelated whitespace issue Co-authored-by: Ned Deily <nad@python.org>
* bpo-41873: Add vectorcall for float() (GH-22432)Dennis Sweeney2020-09-291-0/+3
|
* bpo-38629: implement __floor__ and __ceil__ for float type (GH-16985)Batuhan Taşkaya2019-12-151-0/+28
|
* bpo-20092. Use __index__ in constructors of int, float and complex. (GH-13108)Serhiy Storchaka2019-06-011-0/+15
|
* bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)Serhiy Storchaka2019-03-051-9/+8
|
* bpo-35560: Remove assertion from format(float, "n") (GH-11288)Xtreak2019-01-071-0/+19
| | | | | Fix an assertion error in format() in debug build for floating point formatting with "n" format, zero padding and small width. Release build is not impacted. Patch by Karthikeyan Singaravelan.
* bpo-34087: Fix buffer overflow in int(s) and similar functions (GH-8274)INADA Naoki2018-07-141-0/+3
| | | | | | `_PyUnicode_TransformDecimalAndSpaceToASCII()` missed trailing NUL char. It caused buffer overflow in `_Py_string_to_number_with_underscores()`. This bug is introduced in 9b6c60cb.
* bpo-31979: Simplify transforming decimals to ASCII (#4336)Serhiy Storchaka2017-11-131-1/+1
| | | | | in int(), float() and complex() parsers. This also speeds up parsing non-ASCII numbers by around 20%.
* bpo-31373: remove overly strict float range checks (#3486)Benjamin Peterson2017-09-111-0/+6
| | | | | This undoes a853a8ba7850381d49b284295dd6f0dc491dbe44 except for the pytime.c parts. We want to continue to allow IEEE 754 doubles larger than FLT_MAX to be rounded into finite floats. Tests were added to very this behavior.
* bpo-29773: Add more cases for testing string to float conversion errors. (#580)Serhiy Storchaka2017-03-091-8/+20
|
* bpo-29695: Remove bad keyword parameters in int(), bool(), float(), list() ↵Serhiy Storchaka2017-03-061-2/+2
| | | | and tuple(). (#518)
* bpo-29695: Deprecated using bad named keyword arguments in builtings: (#486)Serhiy Storchaka2017-03-051-0/+4
| | | | int(), bool(), float(), list() and tuple(). Specify the value as a positional argument instead.
* Issue #26331: Implement the parsing part of PEP 515.Brett Cannon2016-09-091-1/+23
| | | | Thanks to Georg Brandl for the patch.
* Issue #26983: float() now always return an instance of exact float.Serhiy Storchaka2016-06-031-8/+13
| | | | | | The deprecation warning is emitted if __float__ returns an instance of a strict subclass of float. In a future versions of Python this can be an error.
* Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses.Serhiy Storchaka2016-05-121-0/+18
|\
| * Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses.Serhiy Storchaka2016-05-121-0/+18
| |
* | Issue #23277: Remove unused imports in tests.Serhiy Storchaka2016-04-241-1/+0
|/
* Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-0/+15
|\ | | | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
| * Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-0/+15
| | | | | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
* | Issue #24802: Merge null termination fixes from 3.4 into 3.5Martin Panter2015-11-071-2/+36
|\ \ | |/
| * Issue #24802: Copy bytes-like objects to null-terminated buffers if necessaryMartin Panter2015-11-071-2/+36
| | | | | | | | | | | | | | | | This avoids possible buffer overreads when int(), float(), compile(), exec() and eval() are passed bytes-like objects. Similar code is removed from the complex() constructor, where it was not reachable. Patch by John Leitch, Serhiy Storchaka and Martin Panter.
* | Issue 19933: Provide default argument for ndigits in round. Patch by ↵Steve Dower2015-04-151-0/+8
| | | | | | | | Vajrasky Kok.
* | Issue #21741: Update 147 test modules to use test discovery.Zachary Ware2015-04-131-14/+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.
* fix up import styleBenjamin Peterson2015-03-091-5/+8
|
* remove redundant testBenjamin Peterson2015-03-061-5/+0
|
* fix potential refleak in PyFloat_AsDouble (closes #23590)Benjamin Peterson2015-03-061-0/+6
|
* Issue 19572: More silently skipped tests explicitly skipped.Zachary Ware2013-12-081-1/+1
|\
| * Issue 19572: More silently skipped tests explicitly skipped.Zachary Ware2013-12-081-1/+1
| |