aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_complex.py
Commit message (Collapse)AuthorAge
* gh-128770: raise warnings as errors in test suite - except for test_socket ↵Thomas Grainger2025-03-27
| | | | | which still logs warnings, and internal test warnings that are now logged (#128973) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-120010: Fix invalid (nan+nanj) results in _Py_c_prod() (GH-120287)Sergey B Kirpichev2024-12-06
| | | | | | | | | | | | | | | | | | | | In some cases, previously computed as (nan+nanj), we could recover meaningful component values in the result, see e.g. the C11, Annex G.5.1, routine _Cmultd(): >>> z = 1e300+1j >>> z*(nan+infj) # was (nan+nanj) (-inf+infj) That also fix some complex powers for small integer exponents, computed with optimized algorithm (by squaring): >>> z**5 # was (nan+nanj) Traceback (most recent call last): File "<python-input-1>", line 1, in <module> z**5 ~^^~ OverflowError: complex exponentiation
* gh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)Sergey B Kirpichev2024-11-26
| | | | | | | | | | | | | | | "Generally, mixed-mode arithmetic combining real and complex variables should be performed directly, not by first coercing the real to complex, lest the sign of zero be rendered uninformative; the same goes for combinations of pure imaginary quantities with complex variables." (c) Kahan, W: Branch cuts for complex elementary functions. This patch implements mixed-mode arithmetic rules, combining real and complex variables as specified by C standards since C99 (in particular, there is no special version for the true division with real lhs operand). Most C compilers implementing C99+ Annex G have only these special rules (without support for imaginary type, which is going to be deprecated in C2y).
* gh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211)Sergey B Kirpichev2024-11-23
| | | `x**y == 1/x**-y ` thus changing `/=` to `*=` by negating the exponent.
* gh-121039: add Floats/ComplexesAreIdenticalMixin to test.support.testcase ↵Sergey B Kirpichev2024-09-08
| | | | (GH-121071)
* gh-121905: Consistently use "floating-point" instead of "floating point" ↵Serhiy Storchaka2024-07-19
| | | | (GH-121907)
* gh-84978: Add float.from_number() and complex.from_number() (GH-26827)Serhiy Storchaka2024-07-15
| | | | | | They are alternate constructors which only accept numbers (including objects with special methods __float__, __complex__ and __index__), but not strings.
* gh-119372: Recover inf's and zeros in _Py_c_quot (GH-119457)Sergey B Kirpichev2024-06-29
| | | | | | In some cases, previously computed as (nan+nanj), we could recover meaningful component values in the result, see e.g. the C11, Annex G.5.2, routine _Cdivd().
* gh-109218: Deprecate weird cases in the complex() constructor (GH-119620)Serhiy Storchaka2024-05-30
| | | | | | | * Passing a string as the "real" keyword argument is now an error; it should only be passed as a single positional argument. * Passing a complex number as the "real" or "imag" argument is now deprecated; it should only be passed as a single positional argument.
* gh-109218: Refactor tests for the complex() constructor (GH-119635)Serhiy Storchaka2024-05-30
| | | | | | | | | | * Share common classes. * Use exactly representable floats and exact tests. * Check the sign of zero components. * Remove duplicated tests (mostly left after merging int and long). * Reorder tests in more consistent way. * Test more error messages. * Add tests for missed cases.
* gh-109802: Add coverage test for complex_abs() (GH-117449)Sergey B Kirpichev2024-04-04
| | | | | | | | * gh-109802: Add coverage test for complex_abs() This tests overflow on L594. // line numbers wrt to 0f2fa6150b
* gh-109802: Increase test coverage for complexobject.c (GH-112452)Sergey B Kirpichev2023-11-28
|
* gh-104263: Rely on Py_NAN and introduce Py_INFINITY (GH-104202)Sebastian Berg2023-05-10
| | | | | | | | | | 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-99320: remove tests for old-style class from `test_complex` (#99321)Nikita Sobolev2022-11-10
|
* bpo-45229: Remove test_main in many tests (GH-28405)Serhiy Storchaka2021-09-19
| | | | | | | | | Instead of explicitly enumerate test classes for run_unittest() use the unittest ability to discover tests. This also makes these tests discoverable and runnable with unittest. load_tests() can be used for dynamic generating tests and adding doctests. setUpModule(), tearDownModule() and addModuleCleanup() can be used for running code before and after all module tests.
* bpo-24234: implement complex.__complex__ (GH-27887)Mark Dickinson2021-08-23
| | | Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* bpo-44698: Restore complex pow behaviour for small integral exponents (GH-27772)Mark Dickinson2021-08-17
|
* bpo-44698: Fix undefined behaviour in complex exponentiation. (GH-27278)T. Wouters2021-07-26
|
* bpo-41974: Remove complex.__float__, complex.__floordiv__, etc (GH-22593)Serhiy Storchaka2020-10-09
| | | | | | Remove complex special methods __int__, __float__, __floordiv__, __mod__, __divmod__, __rfloordiv__, __rmod__ and __rdivmod__ which always raised a TypeError.
* bpo-41055: Remove outdated tests for the tp_print slot. (GH-21006)Serhiy Storchaka2020-06-21
|
* Re-enable the OverflowError test for test_truediv on test_complex (GH-16591)Dong-hee Na2019-10-10
|
* bpo-20092. Use __index__ in constructors of int, float and complex. (GH-13108)Serhiy Storchaka2019-06-02
|
* bpo-34087: Fix buffer overflow in int(s) and similar functions (GH-8274)INADA Naoki2018-07-14
| | | | | | `_PyUnicode_TransformDecimalAndSpaceToASCII()` missed trailing NUL char. It caused buffer overflow in `_Py_string_to_number_with_underscores()`. This bug is introduced in 9b6c60cb.
* bpo-29894: Deprecate returning an instance of complex subclass from ↵Serhiy Storchaka2017-03-24
| | | | | __complex__. (#798) In a future versions of Python this can be an error.
* bpo-29602: fix signed zero handling in complex constructor. (#203)Mark Dickinson2017-02-20
| | | | | | * Fix incorrect handling of signed zeros for complex-related classes. * Add Misc/NEWS entry.
* Issue #28203: Merge from 3.5Mark Dickinson2016-09-24
|\
| * Issue #28203: Fix incorrect type in error message from complex(1.0, {2:3}). ↵Mark Dickinson2016-09-24
| | | | | | | | Patch by Soumya Sharma.
* | Issue #26331: Implement the parsing part of PEP 515.Brett Cannon2016-09-09
|/ | | | Thanks to Georg Brandl for the patch.
* Issue #22604: Fix assertion error in debug mode when dividing a complex ↵Antoine Pitrou2014-10-10
| | | | number by (nan+0j).
* #17080: improve error message of float/complex when the wrong type is passed.Ezio Melotti2013-11-07
|
* merge 3.3 (#19116)Benjamin Peterson2013-09-29
|\
| * combine two tests to avoid duplicate names (closes #19116)Benjamin Peterson2013-09-29
| |
* | Issue #16290: __complex__ must now always return an instance of complex.Mark Dickinson2012-11-14
|/
* Issue 10625: Add tests for negative zeros in complex str and repr.Eric Smith2010-12-04
|
* Issue #10624: Use support.requires_IEEE_754 in all appropriate tests.Eric Smith2010-12-04
|
* Removed static function complex_format, moved it into complex_repr. Modified ↵Eric Smith2010-12-04
| | | | tests to check both str and repr, which are the same for complex.
* Issue #10557: Fixed error messages from float() and other numericAlexander Belopolsky2010-12-04
| | | | | | types. Added a new API function, PyUnicode_TransformDecimalToASCII(), which transforms non-ASCII decimal digits in a Unicode string to their ASCII equivalents.
* Issue #7094: Add alternate ('#') flag to __format__ methods for float, ↵Eric Smith2010-11-25
| | | | complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
* #9424: Replace deprecated assert* methods in the Python test suite.Ezio Melotti2010-11-20
|
* Issue #9416: Fix some issues with complex formatting where theMark Dickinson2010-08-01
| | | | | | | output with no type specifier failed to match the str output: - format(complex(-0.0, 2.0), '-') omitted the real part from the output, - format(complex(0.0, 2.0), '-') included a sign and parentheses.
* Issue #9011: Tests for Python 3.2's treatment of negated imaginary literals.Mark Dickinson2010-06-30
|
* Issue #8748: Fix two issues with comparisons between complex and integerMark Dickinson2010-05-21
| | | | | | | | | | objects. (1) The comparison could incorrectly return True in some cases (2**53+1 == complex(2**53) == 2**53), breaking transivity of equality. (2) The comparison raised an OverflowError for large integers, leading to unpredictable exceptions when combining integers and complex objects in sets or dicts. Patch by Meador Inge.
* (partially)Florent Xicluna2010-04-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | Merged revisions 79534,79537,79539,79558,79606 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r79534 | florent.xicluna | 2010-03-31 23:21:54 +0200 (mer, 31 mar 2010) | 2 lines Fix test for xml.etree when using a non-ascii path. And use check_warnings instead of catch_warnings. ........ r79537 | florent.xicluna | 2010-03-31 23:40:32 +0200 (mer, 31 mar 2010) | 2 lines Fix typo ........ r79539 | florent.xicluna | 2010-04-01 00:01:03 +0200 (jeu, 01 avr 2010) | 2 lines Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests. ........ r79558 | florent.xicluna | 2010-04-01 20:17:09 +0200 (jeu, 01 avr 2010) | 2 lines #7092: Fix some -3 warnings, and fix Lib/platform.py when the path contains a double-quote. ........ r79606 | florent.xicluna | 2010-04-02 19:26:42 +0200 (ven, 02 avr 2010) | 2 lines Backport some robotparser test and skip the test if the external resource is not available. ........
* Issue #7845: Make 1j.__le__(2j) return NotImplemented rather than raising ↵Mark Dickinson2010-03-13
| | | | TypeError.
* Merged revisions 78329 via svnmerge fromEric Smith2010-02-22
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r78329 | eric.smith | 2010-02-22 13:33:47 -0500 (Mon, 22 Feb 2010) | 1 line Issue #7988: Fix default alignment to be right aligned for complex.__format__. Now it matches other numeric types. ........
* Merged revisions 78249 via svnmerge fromEzio Melotti2010-02-20
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r78249 | ezio.melotti | 2010-02-20 11:40:07 +0200 (Sat, 20 Feb 2010) | 1 line Remove e assertIs definitions and use correct assert* methods. ........
* Remove length limitation on string arguments to complex()Mark Dickinson2009-10-26
|
* convert old fail* assertions to assert*Benjamin Peterson2009-06-30
|
* Issue #5829: complex('1e500') shouldn't raise OverflowErrorMark Dickinson2009-05-20
|
* Issue #3382. float 'F' formatting no longer maps to 'f'. This only affects ↵Eric Smith2009-05-06
| | | | nan and inf.