43 Commits

Author SHA1 Message Date
Sergey B Kirpichev fb69943530 Use explicit kwargs in public API, where possible
Following functions kept:
```pycon
>>> import inspect
... with_args = []
... with_kwargs = []
... for n in dir(mpmath):
...     m = getattr(mpmath, n)
...     try:
...         s = inspect.signature(m)
...     except:
...         continue
...     if any(_.kind == inspect._ParameterKind.VAR_POSITIONAL for _ in s.parameters.values()):
...         for name in s.parameters:
...             if s.parameters[name].kind == inspect._ParameterKind.VAR_POSITIONAL and name == 'args':
...                 with_args.append(n)
...                 break
...     if any(_.kind == inspect._ParameterKind.VAR_KEYWORD for _ in s.parameters.values()):
...         with_kwargs.append(n)
... print(with_args)
... print(with_kwargs)
...
['arange', 'ellipe', 'ellippi', 'linspace', 'matrix', 'ones', 'timing', 'zeros']
['multiplicity', 'timing']
```

We need support for multiple signatures in the first case.  In the
second - it's impossible to implement these functions without kwargs.

Closes #1056
2026-08-04 06:40:53 +03:00
Ayush Baranwal a2e0351345 Add Brent root-finding algorithm (#1103)
Closes #1095
2026-06-19 03:31:16 +03:00
Sergey B Kirpichev 6d10972d64 Revert "Set default solver for findroot() dynamically"
This reverts commit f25a56f132.
2026-06-09 01:46:26 +03:00
Sergey B Kirpichev f25a56f132 Set default solver for findroot() dynamically
Closes #1097
2026-06-07 05:31:56 +03:00
Sergey B Kirpichev 429c1d5ec2 Set dynamic maxsteps value for the bisect method
Closes #285
Closes #339
2026-06-07 05:31:56 +03:00
Sergey B Kirpichev bce4dfb5b4 Correct interval update for Ridder's method
Closes #1094
2026-06-07 05:31:54 +03:00
Ayush Baranwal 44ad9908cc Add ModAB rootfinding algorithm (#1093)
closes #1075
2026-06-07 04:30:24 +03:00
Ayush Baranwal e10416f997 Raise ValueError when same sign at interval boundaries in bisection rootfinding algorithm (#1092) 2026-06-02 11:12:23 +03:00
Sergey B Kirpichev c61d0345b3 Drop useless verify=False from doctest 2025-05-31 03:55:10 +03:00
Sergey B Kirpichev 58859b9acf Fix Anderson docs 2025-05-30 06:04:23 +03:00
Sergey B Kirpichev 8778568951 Avoid using ";" in doctests, esp with side effects
The new CPython repl hide all output, except for the last statement.
See https://github.com/python/cpython/issues/131217.
2025-05-01 10:41:48 +03:00
Sergey B Kirpichev a217e4b111 Enable trap_complex for MDNewton
Closes #869
2024-09-24 09:17:20 +03:00
Sergey B Kirpichev a580878336 Use mpf's in steffensen() doctest
Closes #838
2024-08-18 12:35:21 +03:00
Sergey B Kirpichev 310e2ea740 Clarify tol and maxsteps options of findroot()
Closes #736
2023-12-01 07:12:36 +03:00
Yclept Nemo 7c228c8797 Fix typo
// taken from #621
2023-09-22 12:04:35 +03:00
Sergey B Kirpichev 5ec9d07dee Reorganize imports in doctests (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 945ca7c281 Add doctest:+ELLIPSIS 2023-04-30 08:54:49 +03:00
Sergey B Kirpichev 088e27eca1 Drop runtests.py and doctests() function
We use pytest for tests, it has everything that runtests.py has,
including support for profiling (pytest-profiling plugin).

So, let's drop this legacy stuff to avoid bugs like #579.
2023-04-30 08:53:44 +03:00
Fangchen Li dfc289289d Drop py2 support (#629)
* remove xrange compat shim
* remove str compat shim
* remove exec compat shim
* remove object from class defination
* remove misc workarounds for python versions <3.5
* remove __future__ imports
* update readme
* Update setup.cfg

Closes #594

Co-authored-by: Fredrik Johansson <fredrik.johansson@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Colin B. Macdonald <cbm@m.fsf.org>
2023-03-30 04:50:18 +03:00
Christian Clauss 6489ed3bc1 Fix pycodestyle errors E703, E712, E713 (#665) 2023-03-28 10:29:30 +03:00
Maximilian Gaukler 4b5f1e3735 remove force_type arguments, they were broken
Make matrices type-stable, not allowing mixed types in one matrix. Always use the type of the context.
Therefore, specifying an element type by the "force_type" argument does not make sense.

It did not work properly before either, the data was not stored in the given type:
```
>>> M = mpmath.matrix(mpmath.matrix([[0,1,2]]), force_type=bool)
>>> M
matrix(
[['0.0', '1.0', '1.0']])
>>> type(M[0,0])
<class 'mpmath.ctx_mp_python.mpf'>
>>> M._matrix__data
{(0, 1): mpf('1.0'), (0, 2): mpf('1.0')}
```

Now the argument is removed and gives a warning instead:
>>> mpmath.matrix(mpmath.matrix([[0,1,2]]), force_type=bool)
/mpmath/mpmath/matrices/matrices.py:288: UserWarning: The force_type argument was removed, it did not work properly anyway. If you want to force floating-point or interval computations, use the respective methods from `fp` or `mp` instead, e.g., `fp.matrix()` or `iv.matrix()`. If you want to truncate values to integer, use .apply(int) instead.
  warnings.warn("The force_type argument was removed, it did not work"
matrix([['0.0', '1.0', '2.0']])
2021-01-22 20:18:22 +01:00
Sergey B Kirpichev 03b7514510 Drop dependency on six and implement exec() function for py2
We use "imports from future" to get print() function.
2019-02-03 15:00:19 +03:00
Sergey B Kirpichev 82f12a14d1 Add check for empty iterable in findroot()
Slighly different fix than fredrik-johansson/mpmath#410 and
more tests.

Closes #401
Closes #192
Closes #387
2018-10-13 20:43:11 +03:00
Fredrik Johansson dcba1419b8 Merge pull request #356 from paulmasson/patch-3
Minor documentation update
2017-06-18 17:10:02 +02:00
Paul Masson 763d71b506 Minor documentation update 2017-05-24 18:39:09 -07:00
Aaron Meurer d7eafcbfcb Fix failing doctest 2017-04-07 13:53:35 -04:00
Aaron Meurer 58da32e20e Use %s instead of %g in findroot error
This fixes incorrect cutoff for tolerances that don't fit in a Python float.

This causes the error message to be longer, especially when the precision is
set high. Perhaps there is a better way to only print a few digits without
using %g.

Fixes an issue mentioned in #339.
2016-12-29 11:11:16 -07:00
Tomasz Buchert fe80809f1a correct docs on findroot 2015-06-21 20:38:47 +02:00
Sergey B Kirpichev d8f074e245 Workaround for pypy in the steffensen's doctest 2014-04-16 17:58:19 +04:00
Sergey B Kirpichev 006c2c843f Fix steffensen doctest 2014-04-16 17:50:38 +04:00
Sergey B Kirpichev a162d13f0c Change imports for optimization module 2014-04-16 17:50:38 +04:00
Ondřej Čertík 89c636f5dc Normalize line endings 2014-04-14 12:49:26 -06:00
Fredrik Johansson 316f8bf9c7 fix problem with bisection root-finding (issue 233) 2013-04-25 19:25:18 +02:00
Fredrik Johansson 63b247c5cf fix a bunch of doctests 2012-12-31 00:41:44 +01:00
Fredrik Johansson 3296b4a241 fix broken links in documentation (issue 206, patch submitted by gdrummo...@gmail.com) 2011-03-23 00:00:25 +00:00
Fredrik Johansson 5c8e4aa5b4 import xrange from libmp.backend to work in python 3 2011-01-08 22:54:03 +00:00
Fredrik Johansson 26fc5847cb don't use unicode string literal 2011-01-08 22:44:14 +00:00
Fredrik Johansson c357bffb12 put parentheses in a raise statement 2011-01-08 22:43:34 +00:00
Fredrik Johansson d6a6afcdbd python 3-compatible print statements (not fully verified yet) 2011-01-08 22:38:25 +00:00
Fredrik Johansson 27eab13de6 convert line endings in trunk to unix format; rebuild docs 2010-07-28 20:09:06 +00:00
Fredrik Johansson 37955c3804 add mpmath namespace to all :func: references so sphinx will generate links 2010-03-23 15:58:12 +00:00
Fredrik Johansson 09a3e1cd21 consistent line endings 2010-02-04 14:43:01 +00:00
Fredrik Johansson 2413d1a18b moving modules to subdirectories: mpmath/libmp, mpmath/calculus, mpmath/functions 2010-01-12 18:19:42 +00:00