scipyx
SciPy is large library used everywhere in scientific computing. That's why breaking backwards-compatibility comes as a significant cost and is almost always avoided, even if the API of some methods is arguably lacking. This package provides drop-in wrappers "fixing" those.
If you have a fix for a SciPy method that can't go upstream for some reason, feel free to PR here.
Krylov methods
import numpy as np
import scipy.sparse
import scipyx as spx
# create tridiagonal (-1, 2, -1) matrix
n = 100
data = -np.ones((3, n))
data[1] = 2.0
A = scipy.sparse.spdiags(data, [-1, 0, 1], n, n)
A = A.tocsr()
b = np.ones(n)
sol, info = spx.cg(A, b, tol=1.0e-10)
sol, info = spx.minres(A, b, tol=1.0e-10)
sol, info = spx.gmres(A, b, tol=1.0e-10)
sol, info = spx.bicg(A, b, tol=1.0e-10)
sol, info = spx.bicgstab(A, b, tol=1.0e-10)
sol, info = spx.cgs(A, b, tol=1.0e-10)
sol, info = spx.qmr(A, b, tol=1.0e-10)
sol is the solution of the linear system A @ x = b (or None if no convergence),
and info contains some useful data, e.g., info.resnorms. The solution sol and all
callback x have the shape of x0/b.
The methods are wrappers around SciPy's iterative
solvers.
Relevant issues:
Optimization
import scipyx as spx
def f(x):
return (x ** 2 - 2) ** 2
x0 = 1.5
out = spx.minimize(f, x0)
print(out.x)
x0 = -3.2
x, _ = spx.leastsq(f, x0)
print(x)
In scipyx, all intermediate values x and the result from a minimization out.x will
have the same shape as x0. (In SciPy, they always have shape (n,), no matter the
input vector.)
Relevant issues:
Root-finding
import scipyx as spx
def f(x):
return x ** 2 - 2
a, b = spx.bisect(f, 0.0, 5.0, tol=1.0e-12)
a, b = spx.regula_falsi(f, 0.0, 5.0, tol=1.0e-12)
scipyx provides some basic nonlinear root-findings algorithms: bisection and regula falsi. They're not as fast-converging as other methods, but are very robust and work with almost any function.
Rolling Lagrange interpolation
import numpy as np
import scipyx as spx
x = np.linspace(0.0, 1.0, 11)
y = np.sin(7.0 * x)
poly = spx.interp_rolling_lagrange(x, y, order=3)
Given an array of coordinates x and an array of values y, you can use scipyx to
compute a piecewise polynomial Lagrange approximation. The order + 1 closest
coordinates x/y are considered for each interval.
| Order 0 | Order 1 | Order 2 |
Jacobi elliptic functions with complex argument
SciPy supports
Jacobi elliptic functions as
ellipj.
Unfortunately, only real-valued argument u and parameter m are allowed. scipyx
expands support to complex-valued argument u.
import scipyx as spx
u = 1.0 + 2.0j
m = 0.8
# sn, cn, dn, ph = scipy.special.ellipj(x, m) # not working
sn, cn, dn, ph = spx.ellipj(u, m)
Relevant bug reports:
License
This software is published under the BSD-3-Clause license.
Metadata
Release files for scipyx 0.0.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| scipyx-0.0.18.tar.gz | 10.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scipyx-0.0.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.7 kB
Release files / scipyx-0.0.18.tar.gz
| Download URL | scipyx-0.0.18.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7abfb1f33ee28e107c4dfb01e2c631a1718f5e1c49b2ee93c8b2c1826d21de0a
|
|
BLAKE2b-256 checksum How to use checksums |
f1bba42672d76ba9e930455da76b993c2b3e89a30eef56e4a285ac3cce136246
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0+
|
Release files / scipyx-0.0.18-py3-none-any.whl
| Download URL | scipyx-0.0.18-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd353aa6bb303dcf0aad5aba91c64721cf875f4a3345cda37e4ea1aa8ebf8240
|
|
BLAKE2b-256 checksum How to use checksums |
018aed7cad0cb4d826b3b47d1e1f7b09b4b0e18b0b86d98f6ea88856923660d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0+
|