SciPy fixes and extensions
Project description
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 methods are wrappers
around SciPy's iterative
solvers.
Relevant issues:
Minimization
import scipyx as spx
def f(x):
return (x ** 2 - 2) ** 2
x0 = 1.5
out = spx.minimize(f, x0)
In SciPy, the result from a minimization out.x
will always have shape (n,)
, no
matter the input vector. scipyx changes this to respect the input vector shape.
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.
License
scipyx is published under the MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file scipyx-0.0.12.tar.gz
.
File metadata
- Download URL: scipyx-0.0.12.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bf09c003dbf9ae449f9dadf3c35ab4e86d22e7b6a052dce8f725834b0415d8a |
|
MD5 | 9f8726ca1a024072693080848bd70804 |
|
BLAKE2b-256 | 6071305ef26c97166a96714286c940a7592c0f1663209935bab90278b59d14b8 |
File details
Details for the file scipyx-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: scipyx-0.0.12-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bc721ff983417807169049adde3fede38ee1d969efbaf3e1a46ecd95ff44055 |
|
MD5 | e488358a96af35820ac9f54a55111592 |
|
BLAKE2b-256 | 33e97fe301ef81a7a479b4e42459663a3c962f44ce21b5f8b180942ae01b3d3b |