Commit Graph

28 Commits

Author SHA1 Message Date
Sergey B Kirpichev 57efbdc101 Drop resetting globals (mp.prec and so on) in doctests 2023-04-20 12:55:47 +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
Sergey B Kirpichev 0249d97d28 Add rationals converter for mpf()
Closes #465
2023-03-26 04:34:37 +03:00
Sergey B Kirpichev 7503cedaf5 Merge branch 'master' into fix-mpf-inf 2021-03-02 17:45:54 +03:00
Sergey B Kirpichev 0147fea4f7 Remove inaccessible logic in fsum/fdot 2019-03-20 14:58:43 +03:00
Sergey B Kirpichev 4990fb5cf3 Fix syntax warnings on CPython 3.8
Closes #444
2019-03-20 14:25:32 +03:00
Sergey B Kirpichev 1e80ccbb1c Correct mpf initialization from tuple for f(n)inf/fnan
Closes #438
2019-02-16 00:11:26 +03:00
Jonathan Warner d2f54a3efb Improved numpy support
numpy numeric types now work with convert.
Also added support for Fraction and Decimal types.
Added a test and tested on Python 2.7 and 3.5.
Response to issue fredrik-johansson#382
2018-10-18 01:51:53 -06:00
Nico Schlömer 83d4a3e994 allow for numpy arrays in fdot() 2018-02-18 17:42:21 +01:00
Fredrik Johansson f2d6ae74fc change float() and complex() to use context's rounding mode (nearest by default) instead of truncating 2016-03-22 13:22:35 +01:00
Stefan Krastanov e688746a68 Catch ImportError of numbers ABC on 2.5 2012-11-23 16:07:05 +01:00
Stefan Krastanov 7585100bc0 Add initial ABC support.
We do not use subclassing in order to keep it as simple as possible. This
precludes the use of `@abstractmethod`, however it keeps the
`__init__`/`__new__` unchanged.

Not using subclassing/`@abstractmethod` means that checks whether the inferface
conforms to the requirements of the ABC are not done. Given the simplicity of
the interface in our case, this is the prefered approach. Conformity of the
interface is checked durring developpement.

Examples
========

`issubclass` works as well.

```
In [12]: import numbers

In [13]: import mpmath

In [14]: isinstance(mpmath.mpf(0.23), numbers.Complex)
Out[14]: True

In [15]: isinstance(mpmath.mpf(0.23), numbers.Real)
Out[15]: True

In [16]: isinstance(mpmath.mpf(0.23), numbers.Rational)
Out[16]: False
```

```
In [18]: isinstance(mpmath.mpc(0.23), numbers.Complex)
Out[18]: True

In [19]: isinstance(mpmath.mpc(0.23), numbers.Real)
Out[19]: False
```

```
In [20]: isinstance(mpmath.mpi(0.23), numbers.Complex)
Out[20]: True

In [21]: isinstance(mpmath.mpi(0.23), numbers.Real)
Out[21]: True

In [22]: isinstance(mpmath.mpi(0.23), numbers.Rational)
Out[22]: False
```

```
In [23]: isinstance(mpmath.mpi(0.23+1j), numbers.Complex)
Out[23]: True

In [24]: isinstance(mpmath.mpi(0.23+1j), numbers.Real)
Out[24]: False
```
2012-11-23 15:27:36 +01:00
Fredrik Johansson e0f6f48e84 fix slowness of repr(constant) at high precision 2011-09-16 17:09:09 +00:00
Fredrik Johansson 55c395be64 ensure that classes are new-style (critical for PyPy performance) 2011-02-03 13:08:12 +00:00
Fredrik Johansson 66e813286b fix some py3 doctest failures 2011-01-28 20:37:56 +00:00
Fredrik Johansson 296892154f fix remaining py3 compatibility issues 2011-01-08 23:52:03 +00:00
Fredrik Johansson 3bb0f4c5cd some more py3 compatibility fixes 2011-01-08 23:11:04 +00:00
Fredrik Johansson b8651c00f1 switch to using explicit relative imports (Python 2.4 compatibility henceforth abandoned) 2011-01-08 22:15:29 +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 24ef677de7 Upgrade interval arithmetic.
* Move everything interval to a separate context (e.g. iv.exp must be used instead of mp.exp)
* Support both real and complex intervals (iv.mpf, iv.mpc)
* Fix interval cos/sin, and remove the old mpf_cos_sin code it depended on. The new interval cos/sin is a bit slower at low precision now, but this can be fixed.
* Implement interval atan2, and exp/log/power for complex intervals
* Move interval<->string code to libmpi
* Some other interface changes

More tests are still needed, and interface/utility functions needs more work.
2010-04-14 15:12:10 +00:00
Fredrik Johansson b013b38481 tidy the mpq type
* don't inherit from tuple
* avoid __cmp__
* fix some operations

TODO: add more tests for it; for more speed, maybe auto-convert integers to ints or use gmpy.mpq
2010-04-06 22:46:17 +00:00
Fredrik Johansson f4c44a8d94 fixes after last commit 2010-03-23 16:03:10 +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 fddf6fa89e improve utility functions
* optimize and improve documentation for floor, ceil, isinf, isnan, isint
* implement nint, frac, isnormal
* fix and document semantics for isinf, isnan, etc
* extend documentation for mag and nint_distance
* add more tests; move tests for utility functions from test_mpmath.py to test_basic_ops.py
2010-03-23 15:20:12 +00:00
Fredrik Johansson 064a692813 support conjugation in fdot 2010-02-13 17:12:36 +00:00
Fredrik Johansson e2157a5a3d copy existing docstring by default 2010-02-06 19:12:49 +00:00
Fredrik Johansson 09a3e1cd21 consistent line endings 2010-02-04 14:43:01 +00:00
Fredrik Johansson c5d1125530 Reorganization to support the improved Cython backend in Sage. A number of internal methods have been renamed in the process. The patch also contains some other optimizations. 2010-02-03 00:56:42 +00:00