summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-102837: more tests for the math module (GH-111930)Sergey B Kirpichev2023-11-131-0/+55
| | | | | | | | | | | | | | Add tests to improve coverage: * fsum: L1369, L1379, L1383, L1412 * trunc: L2081 * log: L2267 * dist: L2577, L2579 * hypot: L2632 * sumprod: L2744, L2754, L2774, L2778, L2781, L2785, L2831, L2835, L2838 * pow: L2982 * prod: L3294, L3308, L3318-3330 // line numbers wrt to 9dc4fb8204
* gh-111342: fix typo in math.sumprod (GH-111416)Sergey B Kirpichev2023-10-281-0/+1
|
* gh-108303: Move all math files to `Lib/test/mathdata/` (#109512)Nikita Sobolev2023-09-211-3/+3
|
* gh-102837: improve test coverage for math module (#102523)Sergey B Kirpichev2023-09-031-0/+41
| | | | | | | | - input checks for math_1(L989), math_1a(L1023), math_2(L1064,L1071), hypot(L2682), log(L2307), ldexp(L2168), ceil(L1165), floor(L1236,L1239) and dist(L2587,L2588,L2628). - drop inaccessible "if" branch (L3518) in perm_comb_small() - improve fsum coverage for exceptional cases (L1433,L1438,L1451,L1497), ditto fmod(L2378) - rewrite modf to fix inaccessible case(L2229), ditto for pow(L2988) (all line numbers are wrt the main branch at 5e6661bce9)
* gh-94906: Support multiple steps in math.nextafter (#103881)Matthias Görgens2023-05-191-3/+17
| | | | | | | This PR updates `math.nextafter` to add a new `steps` argument. The behaviour is as though `math.nextafter` had been called `steps` times in succession. --------- Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* gh-104263: Rely on Py_NAN and introduce Py_INFINITY (GH-104202)Sebastian Berg2023-05-101-2/+2
| | | | | | | | | | 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>
* Revert "gh-89381: Fix invalid signatures of math/cmath.log (#101404)" (#101580)Mark Dickinson2023-02-051-1/+0
| | | This reverts commit 0ef92d979311ba82d4c41b22ef38e12e1b08b13d.
* GH-100485: Create an alternative code path when an accurate fma() ↵Raymond Hettinger2023-02-041-0/+5
| | | | implementation is not available (#101567)
* gh-89381: Fix invalid signatures of math/cmath.log (#101404)Sergey B Kirpichev2023-01-291-0/+1
|
* GH-100485: Add extended accuracy test. Switch to faster fma() based ↵Raymond Hettinger2023-01-281-0/+83
| | | | variant. GH-101383)
* GH-100485: Tweaks to sumprod() (GH-100857)Raymond Hettinger2023-01-081-0/+1
|
* GH-100485: Add math.sumprod() (GH-100677)Raymond Hettinger2023-01-071-0/+166
|
* GH-98897: fix memory leak if `math.dist` raises exception (GH-98898)Kumar Aditya2022-11-011-0/+5
|
* bpo-37295: Use constant-time comb() and perm() for larger n depending on k ↵Serhiy Storchaka2022-01-091-4/+4
| | | | (GH-30305)
* bpo-45917: Add math.exp2() method - return 2 raised to the power of x (GH-29829)Gideon2021-11-291-0/+11
| | | Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-35606: Fix math.prod tests using 'start' as keyword parameter (GH-28595)Pablo Galindo Salgado2021-09-281-6/+12
|
* bpo-5846: Do not use obsolete unittest functions. (GH-28303)Serhiy Storchaka2021-09-131-8/+5
| | | | Get rid of use of makeSuite() and findTestCases(). Also make test_math and test_threading_local discoverable.
* 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.