summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.8] bpo-39871: Fix possible SystemError in atan2, copysign and remainder ↵Mark Dickinson2020-03-141-0/+16
| | | | | | | | | | | | (GH-18806) (GH-18989) In math_2(), the first PyFloat_AsDouble() call should be checked for failure before the second call. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>. (cherry picked from commit 5208b4b37953a406db0ed6a9db545c2948dde989) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* Move test_math tests (GH-18098) (GH-18102)Victor Stinner2020-01-211-129/+129
| | | | | testPerm() and testComb() belong to MathTests, not to IsCloseTests(). (cherry picked from commit 59e2d26b258c12f18d8d2e789ef741703d6c52d5)
* bpo-38992: avoid fsum test failure from constant-folding (GH-17513) (GH-17530)Miss Islington (bot)2019-12-091-1/+7
| | | | | | | | * Issue 38992: avoid fsum test failure * Add NEWS entry (cherry picked from commit bba873e633f0f1e88ea12fb935cbd58faa77f976) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* bpo-37691: Let math.dist() accept sequences and iterables for coordinates ↵Miss Islington (bot)2019-07-271-2/+4
| | | | | | | (GH-14975) (GH-14984) (cherry picked from commit 6b5f1b496f0b20144592b640b9c975df43a29eb0) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* [3.8] Fix typos in docs, comments and test assert messages (GH-14872). (#14900)Kyle Stanley2019-07-221-2/+2
| | | | | (cherry picked from commit 96e12d5f4f3c5a20986566038ee763dff3c228a1) Co-authored-by: Min ho Kim <minho42@gmail.com>
* Remove unused imports in tests (GH-14518) (GH-14520)Victor Stinner2019-07-011-1/+1
| | | (cherry picked from commit 8f4ef3b019ce380022018587571b0f970e668de3)
* [3.8] bpo-35431: Test math.comb() and math.perm() for OverflowError only on ↵Serhiy Storchaka2019-06-231-3/+5
| | | | | | | CPython. (GH-14146) (#14226) Other implementation can raise MemoryError, but it can takes hours. (cherry picked from commit 1b8a46d59734a77cd1f5ffcf3bdfcaafd58a87e7)
* bpo-37178: Allow a one argument form of math.perm() (GH-13905) (GH-13919)Miss Islington (bot)2019-06-081-2/+7
| | | | | (cherry picked from commit e119b3d136bd94d880bce4b382096f6de3f38062) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* bpo-35431: Drop the k <= n requirement (GH-13798)Raymond Hettinger2019-06-041-6/+6
|
* bpo-37128: Add math.perm(). (GH-13731)Serhiy Storchaka2019-06-021-1/+65
|
* bpo-35431: Refactor math.comb() implementation. (GH-13725)Serhiy Storchaka2019-06-011-7/+22
| | | | | | | * Fixed some bugs. * Added support for index-likes objects. * Improved error messages. * Cleaned up and optimized the code. * Added more tests.
* bpo-35431: Implemented math.comb (GH-11414)Yash Aggarwal2019-06-011-0/+51
|
* bpo-36957: Speed up math.isqrt (#13405)Mark Dickinson2019-05-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add math.isqrt function computing the integer square root. * Code cleanup: remove redundant comments, rename some variables. * Tighten up code a bit more; use Py_XDECREF to simplify error handling. * Update Modules/mathmodule.c Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Update Modules/mathmodule.c Use real argument clinic type instead of an alias Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Add proof sketch * Updates from review. * Correct and expand documentation. * Fix bad reference handling on error; make some variables block-local; other tidying. * Style and consistency fixes. * Add missing error check; don't try to DECREF a NULL a * Simplify some error returns. * Another two test cases: - clarify that floats are rejected even if they happen to be squares of small integers - TypeError beats ValueError for a negative float * Add fast path for small inputs. Needs tests. * Speed up isqrt for n >= 2**64 as well; add extra tests. * Reduce number of test-cases to avoid dominating the run-time of test_math. * Don't perform unnecessary extra iterations when computing c_bit_length. * Abstract common uint64_t code out into a separate function. * Cleanup. * Add a missing Py_DECREF in an error branch. More cleanup. * Update Modules/mathmodule.c Add missing `static` declaration to helper function. Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Add missing backtick.
* bpo-36887: add math.isqrt (GH-13244)Mark Dickinson2019-05-181-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add math.isqrt function computing the integer square root. * Code cleanup: remove redundant comments, rename some variables. * Tighten up code a bit more; use Py_XDECREF to simplify error handling. * Update Modules/mathmodule.c Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Update Modules/mathmodule.c Use real argument clinic type instead of an alias Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Add proof sketch * Updates from review. * Correct and expand documentation. * Fix bad reference handling on error; make some variables block-local; other tidying. * Style and consistency fixes. * Add missing error check; don't try to DECREF a NULL a * Simplify some error returns. * Another two test cases: - clarify that floats are rejected even if they happen to be squares of small integers - TypeError beats ValueError for a negative float * Documentation and markup improvements; thanks Serhiy for the suggestions! * Cleaner Misc/NEWS entry wording. * Clean up (with one fix) to the algorithm explanation and proof.
* Rework integer overflow path in math.prod and add more tests (GH-11809)Pablo Galindo2019-03-091-35/+86
| | | | | The overflow check was relying on undefined behaviour as it was using the result of the multiplication to do the check, and once the overflow has already happened, any operation on the result is undefined behaviour. Some extra checks that exercise code paths related to this are also added.
* Fix division by 0 when checking for overflow in math.prod (GH-11808)Pablo Galindo2019-02-101-0/+4
|
* bpo-35606: Implement math.prod (GH-11359)Pablo Galindo2019-02-071-0/+31
|
* Fast path for int inputs to math.dist() and math.hypot() (GH-11692)Raymond Hettinger2019-01-281-1/+10
|
* bpo-34838: Use subclass_of for math.dist. (GH-9659)Ammar Askar2019-01-121-0/+2
| | | | | Argument clinic now generates fast inline code for positional parsing, so the manually implemented type check in math.dist can be removed.
* closes bpo-34640: Remove the TANH_PRESERVES_ZERO_SIGN configure check. (GH-9206)Benjamin Peterson2018-09-121-2/+0
|
* bpo-33083 - Make math.factorial reject arguments that are not int-like (GH-6149)Pablo Galindo2018-09-031-0/+5
| | | math.factorial() was accepting non-integral Decimal instances. This is inconsistent with the actual behaviour for floats, which are not accepted.
* Add more tests and assertions for math.hypot() and math.dist() (GH-8747)Raymond Hettinger2018-08-121-5/+12
|
* bpo-33089: Add math.dist() for computing the Euclidean distance between two ↵Raymond Hettinger2018-07-311-0/+103
| | | | points (GH-8561)
* bpo-33089: Multidimensional math.hypot() (GH-8474)Raymond Hettinger2018-07-281-10/+66
|
* bpo-32297: Few misspellings found in Python source code comments. (#4803)Mike2017-12-141-1/+1
| | | | | | | | * Fix multiple typos in code comments * Add spacing in comments (test_logging.py, test_math.py) * Fix spaces at the beginning of comments in test_logging.py
* bpo-29962: add math.remainder (#950)Mark Dickinson2017-04-051-0/+135
| | | | | | | | | | | | | | * Implement math.remainder. * Fix markup for arguments; use double spaces after period. * Mark up function reference in what's new entry. * Add comment explaining the calculation in the final branch. * Fix out-of-order entry in whatsnew. * Add comment explaining why it's good enough to compare m with c, in spite of possible rounding error.
* Issue #29282: Backed out changeset b33012ef1417Mark Dickinson2017-01-211-234/+0
|
* Issue #29282: add fused multiply-add function, math.fma.Mark Dickinson2017-01-211-0/+234
|
* Issue #27427: Additional tests for the math module. Thanks Francisco Couzo.Mark Dickinson2016-09-041-6/+22
|
* Issue #27953: skip failing math and cmath tests for tan on OS X 10.4.Mark Dickinson2016-09-041-1/+18
|
* Issue #26040: Improve test_math and test_cmath coverage and rigour. Thanks ↵Mark Dickinson2016-09-031-87/+178
| | | | Jeff Allen.
* Issue #12345: Add mathemathcal constant tau to math and cmath.Guido van Rossum2016-08-151-0/+1
| | | | Patch by Lisa Roach. See also PEP 628.
* Issue #27626: Merge spelling fixes from 3.5Martin Panter2016-07-281-2/+2
|\
| * Issue #27626: Spelling fixes in docs, comments and internal namesMartin Panter2016-07-281-2/+2
| | | | | | | | Based on patch by Ville Skyttä.
* | Issue #23277: Remove unused imports in tests.Serhiy Storchaka2016-04-241-1/+0
|/
* Issue #19543: Implementation of isclose as per PEP 485Tal Einat2015-05-311-0/+121
| | | | | | | | | For details, see: PEP 0485 -- A Function for testing approximate equality Functions added: math.isclose() and cmath.isclose(). Original code by Chris Barker. Patch by Tal Einat.
* Issue #22486: Added the math.gcd() function. The fractions.gcd() function ↵Serhiy Storchaka2015-05-121-0/+51
| | | | | | now is deprecated. Based on patch by Mark Dickinson.
* Issue #23185: add math.inf and math.nan constants.Mark Dickinson2015-01-111-0/+11
|
* Issue #20539: Improve math.factorial error messages and types for large inputs.Mark Dickinson2014-04-101-2/+10
| | | | | - Better message for the OverflowError in large positive inputs. - Changed exception type from OverflowError to ValueError for large negative inputs.
* Issue #18702: All skipped tests now reported as skipped.Serhiy Storchaka2013-11-031-31/+30
|
* (Merge 3.2) Close #12230: Mac OS X Tiger (10.4) has a kernel bug: sometimes,Victor Stinner2011-06-011-3/+2
|\ | | | | | | | | | | | | | | | | the file descriptor of a pipe closed in the parent process is valid in the child process according to fstat(), but the mode of the file descriptor is invalid, and read or write raise an error. test.support.requires_mac_ver() is now a decorator, as suggested by Ezio Melotti, and its docstring is fixed (linux_version => mac_ver).
* | test.support: add requires_mac_ver() functionVictor Stinner2011-06-011-3/+4
| | | | | | | | Add also linux_version() to __all__.
* | Issue #11888: skip some log2 tests on Mac OS X TigerVictor Stinner2011-05-101-4/+11
| | | | | | | | System log2() is not accurate for exact power of 2.
* | Issue #11188: In log2 tests, create powers of 2 using ldexp(1, n) instead of ↵Mark Dickinson2011-05-091-2/+2
| | | | | | | | the less reliable 2.0**n.
* | Issue #11888: Add log2 function to math module. Patch written by MarkVictor Stinner2011-05-081-0/+22
| | | | | | | | Dickinson.
* | test_math.py: Use correct signs on zeros for expected fmod results.Mark Dickinson2011-05-031-6/+6
| |
* | Remove an unused import and an unused local definition from test_math.py.Mark Dickinson2011-05-031-2/+0
|/
* #11565: Merge with 3.1.Ezio Melotti2011-03-161-1/+1
|\
| * #11565: Fix several typos. Patch by Piotr Kasprzyk.Ezio Melotti2011-03-161-1/+1
| |
| * Merged revisions 86596 via svnmerge fromEzio Melotti2010-11-211-59/+59
| | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86596 | ezio.melotti | 2010-11-20 21:04:17 +0200 (Sat, 20 Nov 2010) | 1 line #9424: Replace deprecated assert* methods in the Python test suite. ........