1402 Commits

Author SHA1 Message Date
fredrik d806af3a63 version 1.2.0
test / build (2.7) (push) Has been cancelled
test / build (3.10-dev) (push) Has been cancelled
test / build (3.4) (push) Has been cancelled
test / build (3.5) (push) Has been cancelled
test / build (3.6) (push) Has been cancelled
test / build (3.7) (push) Has been cancelled
test / build (3.8) (push) Has been cancelled
test / build (3.9) (push) Has been cancelled
test / build (pypy2) (push) Has been cancelled
test / build (pypy3) (push) Has been cancelled
1.2.0
2021-02-01 22:26:49 +01:00
Fredrik Johansson c733d675e0 Merge pull request #566 from MaxGaukler/fix-remove-forcetype
remove force_type arguments, they were broken
2021-01-30 14:11:10 +01: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
Fredrik Johansson b8be2f5836 Merge pull request #531 from MaxGaukler/fix-iv-matmul
Fix initialization of iv.matrix from non-interval matrix
2021-01-22 17:30:04 +01:00
Maximilian Gaukler 58a597d5a1 Fix initialization of iv.matrix from non-interval matrix
Non-interval datatypes were not converted to intervals, resulting in unexpected behavior. For example, M[i, j] didn't return mpi interval objects, but mpf floats, so M[i, j] * M[k, l] and, under certain conditions, M * M, was not performed as interval multiplication.

This could have unexpected consequences, as outlined below.

"Exact" computation for reference:
>>> import mpmath
>>> x = mpmath.convert('1.00000000000001') # 1.0000...001 rounded to the next mpf floating point value
>>> mpmath.mp.dps=1000
>>> x*x # Good approximation of x*x
mpf('1.00000000000001998401444325291756783368705994138804689654360263219301518944348572404123842716217041015625')

Interval arithmetic should return an interval containing that value, with some uncertainty.

Restart python to reset mp.dps.
Before this commit, the following occurs:
>>> import mpmath
>>> x = mpmath.convert('1.00000000000001')
>>> x
mpf('1.00000000000001')
>>> A = mpmath.matrix([[x]])
>>> B = mpmath.iv.matrix(A)
>>> C = mpmath.iv.matrix([[x]])
>>> A*A
matrix(
[['1.00000000000002']])
>>> B*B
matrix(
[['[1.000000000000019984, 1.000000000000019984]']])
>>> (B*B)[0,0].delta
mpi('0.0', '0.0')
>>> C*C
matrix(
[['[1.000000000000019984, 1.0000000000000202061]']])

B*B is wrong, the interval width must be nonzero at the default precision of 15 digits.
B*B is different from C*C, although both were initialized from the same numerical value and computed the same way.

After this commit, the result is valid:
>>> B*B
matrix(
[['[1.000000000000019984, 1.0000000000000202061]']])
>>> (B*B)[0,0].delta
mpi('2.2204460492503131e-16', '2.2204460492503131e-16')

Some more insight:

Old incorrect behavior:
>>> mpmath.iv.matrix(mpmath.eye(1))[0,0]
mpf('1.0')

New correct behavior:
>>> mpmath.iv.matrix(mpmath.eye(1))[0,0]
mpf('1.0')
>>> mpmath.iv.eye(1)[0,0]
mpi('1.0', '1.0')

>>> import mpmath
>>> mpmath.iv.matrix(mpmath.eye(1))
matrix(
[['[1.0, 1.0]']])
>>> mpmath.iv.matrix(mpmath.eye(1))[0,0]
mpi('1.0', '1.0')
>>> mpmath.fp.matrix(mpmath.eye(1))[0,0]
1.0
>>> mpmath.matrix(mpmath.eye(1))[0,0]
mpf('1.0')

The type now exactly matches the type returned by the context's matrix functions such as eye():
>>> mpmath.matrix(mpmath.eye(1))[0,0]
mpf('1.0')
>>> mpmath.eye(1)[0,0]
mpf('1.0')
>>> mpmath.iv.matrix(mpmath.eye(1))[0,0]
mpi('1.0', '1.0')
>>> mpmath.iv.eye(1)[0,0]
mpi('1.0', '1.0')
>>> mpmath.fp.matrix(mpmath.eye(1))[0,0]
1.0
>>> mpmath.fp.eye(1)[0,0]
1.0
2021-01-22 08:28:37 +01:00
Fredrik Johansson 1617491d33 Merge pull request #555 from skirpichev/ci-to-gh
Enable testing with the Github Actions
2021-01-20 13:51:33 +01:00
Sergey B Kirpichev c7c1be1b1a Update classifiers (supported CPython versions) 2021-01-20 15:33:03 +03:00
Sergey B Kirpichev 89c702c1ea Enable testing on CPython 3.10 2021-01-20 15:30:25 +03:00
Sergey B Kirpichev e4a9d0c817 3.9-dev -> 3.9 2021-01-20 15:30:25 +03:00
Sergey B Kirpichev 4941d6771e Combine coverage stuff 2021-01-20 15:30:25 +03:00
Sergey B Kirpichev a45c2d35dc Apply review suggestions
1) verbose pip arguments
2) py.test -> pytest
2021-01-20 15:30:25 +03:00
Sergey B Kirpichev 7775622f37 Enable testing with the Github Actions
Closes #553
2021-01-20 15:30:23 +03:00
Fredrik Johansson 8ba6febce0 Merge pull request #554 from skirpichev/fix-ci2
Fix Travis-CI in the master & some cleanup of the Travis config
2021-01-20 10:09:34 +01:00
Sergey B Kirpichev 40e1017187 Enable testing on CPython 3.10 2021-01-03 07:01:23 +03:00
Sergey B Kirpichev 17493191da Merge branch 'master' into fix-ci2 2021-01-03 06:59:42 +03:00
Sergey B Kirpichev 82ae9ffdb5 3.9-dev -> 3.9 2021-01-03 06:58:52 +03:00
Fredrik Johansson 879699c6ae Merge pull request #564 from DamSenViet/preserve-wrapped-signature
PrecisionManager preserves caller signature
2020-12-17 13:47:37 +01:00
Viet Tran f63ffe0f6e Removed redundant lines 2020-12-16 21:41:54 -08:00
DamSenViet f8e8ef13dc PrecisionManager preserves caller signature 2020-12-16 17:44:38 -08:00
Fredrik Johansson 1769b4bf10 Merge pull request #560 from klkuhlm/master
revert previous change that had unintended consequences.
2020-10-26 15:28:23 +01:00
klkuhlm 518a52bda0 revert previous change that had unintended consequences. 2020-10-26 08:03:54 -06:00
Fredrik Johansson d957c3dabe Merge pull request #557 from jwilk-forks/sys.version
Fix sys.version comparisons
2020-10-26 09:05:00 +01:00
Fredrik Johansson 81e696eac8 Merge pull request #559 from klkuhlm/master
pass kwargs to laplace-space function in invertlaplace
2020-10-26 09:04:17 +01:00
klkuhlm cab6cba208 pass kwargs to laplace-space function in invertlaplace 2020-10-25 15:46:32 -06:00
Jakub Wilk 5ad1d2f88d Fix sys.version comparisons
"sys.version >= '3.2'" will break in Python 3.10.
2020-10-12 09:32:28 +02:00
Sergey B Kirpichev c62138cfb4 Apply fixes from the Travis CI build config validation 2020-10-03 05:27:33 +03:00
Sergey B Kirpichev 85cf16c5cb CI: Enable testing on CPython 3.9 2020-10-02 08:30:55 +03:00
Sergey B Kirpichev bbd6e02234 CI: provide pytest-cov arguments with PYTEST_ADDOPTS 2020-10-02 08:30:48 +03:00
Sergey B Kirpichev 59c1b7fde6 CI: reinstall setuptools globally (3.4 goes to the common build matrix) 2020-10-02 08:30:39 +03:00
Sergey B Kirpichev 401a652126 CI: Drop tests on arm64
This reverts c98b4d6.  I believe, for platform-independent
Python library these tests are not needed, even if we add
gmpy-enabled tests.  Right now this only enlarge the build
matrix and slowdown the testing process...
2020-10-02 08:30:02 +03:00
Sergey B Kirpichev f2be673aa8 CI: Set minimal pytest version (fixes testing in Travis-CI) 2020-10-02 08:29:37 +03:00
Fredrik Johansson 77c4c5e0ce Merge pull request #533 from MaxGaukler/fix-scalar-matmul
Fix scalar-matrix-multiplication for mpi * iv.matrix
2020-09-06 10:22:52 +02:00
Fredrik Johansson 6a675bf08e Merge pull request #537 from tminka/quad
QuadratureRule.summation adds the error across intervals
2020-06-08 09:29:40 +02:00
Fredrik Johansson 718b4a1457 Merge pull request #526 from MaxGaukler/pos
Implement unary plus for matrices (+M == M)
2020-06-08 09:27:59 +02:00
Tom Minka adb811b0f5 Added test 2020-05-20 12:45:07 +01:00
Tom Minka 6ef6ac44a9 Fixed broken link in README
Added pytest.ini
2020-05-20 12:37:36 +01:00
Tom Minka 51c63a27d4 QuadratureRule.summation adds the error across intervals 2020-05-15 15:14:45 +01:00
Maximilian Gaukler 5abc70fc9b Implement unary plus for matrices (+M == M rounded to current precision) 2020-04-24 15:10:02 +02:00
Maximilian Gaukler c2d2bf33ab Fix scalar-matrix-multiplication for mpi * iv.matrix 2020-03-24 12:23:07 +01:00
fredrik ffec62b29b Merge branch 'master' of github.com:fredrik-johansson/mpmath 2020-03-23 15:19:32 +01:00
fredrik 28973bc3ba slightly improve elliprj code 2020-03-23 15:19:19 +01:00
Fredrik Johansson deeb2a9cf4 Merge pull request #529 from klkuhlm/master
fixed indexing errors in inverse laplace transform algorithm, as pointed out by Mark Bakker
2020-03-22 18:01:02 +01:00
Fredrik Johansson b217369eee Merge pull request #525 from MaxGaukler/matmul
Support @ for matrix multiplication
2020-03-22 17:55:40 +01:00
klkuhlm c51e3e3dc8 fixed indexing errors in deHoog, Knight & Stokes inverse laplace transform algorithm, as pointed out by Mark Bakker 2020-03-22 09:05:47 -06:00
fredrik b80b8661b6 use integration as workaround where the algorithm for elliprj is not valid 2020-03-22 15:04:04 +01:00
Maximilian Gaukler 7a3bb2883d Support @ operator (PEP465) for matrix multiplication 2020-03-20 12:37:52 +01:00
Fredrik Johansson 411b74d0da Merge pull request #500 from cclauss/modernize-Python-2-codes
Use print() function in both Python 2 and Python 3
2020-02-20 12:06:07 +01:00
Fredrik Johansson c80fc1f55b Merge pull request #501 from ossdev07/arm_support
Adding Travis-Ci Support For Arm64
2020-02-20 12:05:28 +01:00
Fredrik Johansson a64ff99cf0 Merge pull request #502 from paulmasson/master
Modify period of cn
2020-02-20 12:05:06 +01:00
Paul Masson 4fc6783ade Modify period of cn 2020-01-01 15:58:07 -08:00