summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-44339: Fix math.pow corner case to comply with IEEE 754 (GH-26606)Mark Dickinson2021-06-121-2/+2
| | | Change the behaviour of `math.pow(0.0, -math.inf)` and `math.pow(-0.0, -math.inf)` to return positive infinity instead of raising `ValueError`. This makes `math.pow` consistent with the built-in `pow` (and the `**` operator) for this particular special case, and brings the `math.pow` special-case handling into compliance with IEEE 754.
* bpo-44357:Add `math.cbrt()` function: Cube Root (GH-26622)Ajith Ramachandran2021-06-101-0/+16
| | | | | | * Add math.cbrt() function: Cube Root Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-44364:Add non integral tests for `sqrt()` (#26625)Ajith Ramachandran2021-06-101-0/+4
| | | | | * Add non integral tests for `sqrt()` Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145)Inada Naoki2021-04-041-2/+2
| | | | | | | | | | | | | | | | | | | * test_asyncio * test_bz2 * test_math * test_cmath * test_cmd_line * test_cmd_line_script * test_compile * test_contextlib * test_profile * ctypes/test/test_find * test_multiprocessing * test_configparser * test_csv * test_dbm_dumb * test_decimal * test_difflib * os.fdopen() calls io.text_encoding() to emit EncodingWarning for right place.
* Revert "Fix all Python Cookbook links (#22205)" (GH-22424)Andre Delfino2020-09-271-1/+1
| | | This commit reverts commit ac0333e1e117b7f61ed7ef1dbcdb6e515ada603b as the original links are working again and they provide extended features such as comments and alternative versions.
* bpo-41513: Add accuracy tests for math.hypot() (GH-22327)Raymond Hettinger2020-09-211-0/+63
|
* Fix all Python Cookbook links (#22205)Andre Delfino2020-09-151-1/+1
|
* bpo-41513: Remove broken tests that fail on Gentoo (GH-22249)Raymond Hettinger2020-09-151-51/+0
|
* bpo-41513: Add docs and tests for hypot() (GH-22238)Raymond Hettinger2020-09-141-0/+51
|
* bpo-41513: Improve speed and accuracy of math.hypot() (GH-21803)Raymond Hettinger2020-08-161-3/+4
|
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-261-10/+5
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-39871: Fix possible SystemError in atan2, copysign and remainder (GH-18806)Zackery Spytz2020-03-141-0/+16
| | | | | | 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>
* bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments. ↵Serhiy Storchaka2020-02-231-25/+33
| | | | | | | | | | | | | | | | (GH-18604) * bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments. * Simplify fast path. * Difine lcm() without arguments returning 1. * Apply suggestions from code review Co-Authored-By: Mark Dickinson <dickinsm@gmail.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-39479:Add math.lcm() function: Least Common Multiple (#18547)ananthan-1232020-02-191-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update math.rst * Update math.rst * updated whats new * Update test_math.py * Update mathmodule.c * Update mathmodule.c.h * Update ACKS * 📜🤖 Added by blurb_it. * Update 3.9.rst * Update 2020-02-18-12-37-16.bpo-39479.j3UcCq.rst * Update math.rst * Update 2020-02-18-12-37-16.bpo-39479.j3UcCq.rst * Update test_math.py * Update ACKS * Update mathmodule.c.h * Update mathmodule.c * Update mathmodule.c.h * Update mathmodule.c.h Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* Move test_math tests (GH-18098)Victor Stinner2020-01-211-148/+148
| | | | | testPerm() and testComb() belong to MathTests, not to IsCloseTests(). test_nextafter() and test_ulp() now use assertIsNaN().
* bpo-39396: Fix math.nextafter(-0.0, +0.0) on AIX 7.1 (GH-18094)Victor Stinner2020-01-211-77/+77
| | | | Move also math.nextafter() on math.ulp() tests from IsCloseTests to MathTests.
* bpo-39310: Add math.ulp(x) (GH-17965)Victor Stinner2020-01-131-28/+27
| | | | Add math.ulp(): return the value of the least significant bit of a float.
* bpo-39288: Add math.nextafter(x, y) (GH-17937)Victor Stinner2020-01-121-0/+54
| | | Return the next floating-point value after x towards y.
* bpo-38992: avoid fsum test failure from constant-folding (GH-17513)Mark Dickinson2019-12-091-1/+7
| | | | | | * Issue 38992: avoid fsum test failure * Add NEWS entry
* bpo-38639: Optimize floor(), ceil() and trunc() for floats. (GH-16991)Serhiy Storchaka2019-11-161-21/+40
|
* bpo-37691: Let math.dist() accept sequences and iterables for coordinates ↵Raymond Hettinger2019-07-271-2/+4
| | | | (GH-14975)
* Fix typos in docs, comments and test assert messages (#14872)Min ho Kim2019-07-211-2/+2
|
* Remove unused imports in tests (GH-14518)Victor Stinner2019-07-011-1/+1
|
* bpo-36511: Add buildbot scripts and fix tests for Windows ARM32 buildbot ↵Paul Monson2019-06-191-0/+2
| | | | (GH-13454)
* bpo-35431: Test math.comb() and math.perm() for OverflowError only on ↵Serhiy Storchaka2019-06-171-3/+5
| | | | | CPython. (GH-14146) Other implementation can raise MemoryError, but it can takes hours.
* bpo-37315: Deprecate accepting floats in math.factorial(). (GH-14147)Serhiy Storchaka2019-06-171-7/+12
|
* bpo-37178: Allow a one argument form of math.perm() (GH-13905)Raymond Hettinger2019-06-081-2/+7
|
* 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.