sigma-py / orthopy Goto Github PK
View Code? Open in Web Editor NEW:triangular_ruler: Orthogonal polynomials in all shapes and sizes.
:triangular_ruler: Orthogonal polynomials in all shapes and sizes.
Section 5.1 in
Orthogonal polynomials of several variables
Y. Xu, 2017,
https://arxiv.org/pdf/1701.02709.pdf.
Described by, e.g., Gautschi in On generating orthogonal polynomials.
For higher-dimensional polynomials, the fitting data structure for each level would be a numpy.array
of shape (n, n, ...)
, but only the lower (or upper) triangle of (n,n)
is used. Perhaps even more fitting would be to address the entries in "barycentric" coordinates, such that the indices sum up to L
. Check with the product scheme and, perhaps, ndim.
See, e.g., Gautschi's "On orthogonal polynomials".
The Clenshaw algorithm allows the efficient computation of linear combination of recurrence-scheme polynomials. It'd be nice if this could be extended to all of the polynomials classes in orthopy.
(Suggestion by Rob Kirby.)
setup.py
was removed in a recent commit. However, this makes it quite cumbersome to install the package by downloading the package and doing it manually (which is what I am doing).
I.e.
python setup.py install
would fail.python3 -m pep517.build --source --binary .
While pep517 may have gotten traction I would hope that you would re-enable the setup.py
since it is quite convenient until pep517 has stabilized (the pep517.build
documentation clearly states that this is not the final placement).
If you want a minimal setup.py
you could do with:
#!/usr/bin/env python
from setuptools import setup
setup(use_scm_version=True)
and then amend your setup.cfg
with
setup_requires =
setuptools >= 41.2
setuptools_scm
The reason is that I can't figure out how to customize --prefix
with the pep517 command. And this is really necessary when trying to install in non-standard locations.
Basically I cannot do:
python3 -m pep517.build --source . --prefix=<>
Do you know of any other way?
PS. This issue would also apply to quadpy
;)
The scaling (monic, classical, normal) is orthogonal on the standardization (probabilist, physicist).
Aim to make Stroud/Secrest's book of Gaussian tables obsolete.
See bugs
For generating the recursion coefficients from the points and weights, refer to
and the reference
The latter describes one method (3.2. Method 2 – orthogonal reduction) that should be rather easy to implement once scipy/scipy#7775 has been resolved.
The trees have the same algrebraic structure, can be shared in tools.
Singularity-free evaluation of collapsed-coordinate orthogonal polynomials, Robert C. Kirby, Texas Tech University
https://cpb-us-w2.wpmucdn.com/sites.baylor.edu/dist/6/32/files/2015/01/dubrec-1dzeylu.pdf
Is this expected behavior from PYPI? We were using an older version of orthopy and we can no longer install it via pip
.
It would be good if orthopy was usable in environments where matplotlib and/or tk is not installed. Currently it will attempt to import matplotlib, which attempts to set up the tkagg backend, failing to do so because I'm using a Python that was not compiled with tk. It seems a little counterintuitive that I need to have a GUI library compiled with Python for generating quadrature rules (via quadpy).
In the meantime I've had to lift the parts I need out of quadpy into my own modules. This is fine but not ideal. Please consider making the dependency on matplotlib optional.
Hi, from last friday the test were passing, but today when install I have this message. Thanks in advance for support. This is the full log.
===================================================================================== FAILURES ======================================================================================
_________________________________________________________________________________ code block check __________________________________________________________________________________
line 246, line 246:
import orthopy
orthopy.u3.write_tree("u3.vtk", 5, "quantum mechanic")
get_srgb1() got an unexpected keyword argument 'colorspace'
_________________________________________________________________________________ test_write_single _________________________________________________________________________________
n = 5, r = 3
def test_write_single(n=5, r=3):
> orthopy.u3.write_single(f"sph{n}{r}.vtk", n, r, "quantum mechanic")
tests/test_u3.py:142:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
filename = 'sph53.vtk', n = 5, r = 3, scaling = 'quantum mechanic', res = 20
def write_single(filename, n, r, scaling, res=20):
"""This function creates a sphere mesh with "srgb1" values. Can be views in ParaView
by disabling "Map Scalars".
"""
import cplot
import meshio
import meshzoo
points, cells = meshzoo.icosa_sphere(res)
evaluator = EvalCartesian(points.T, scaling, complex_valued=True)
vals = next(itertools.islice(evaluator, n, None))[r]
> srgb1_vals = cplot.get_srgb1(vals, colorspace="cam16")
E TypeError: get_srgb1() got an unexpected keyword argument 'colorspace'
tmp_install/usr/lib/python3.10/site-packages/orthopy/u3/tools.py:21: TypeError
__________________________________________________________________________________ test_write_tree __________________________________________________________________________________
n = 2
def test_write_tree(n=2):
> orthopy.u3.write_tree(f"sph{n}.vtk", n, "quantum mechanic")
tests/test_u3.py:146:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
filename = 'sph2.vtk', n = 2, scaling = 'quantum mechanic', res = 20
def write_tree(filename, n, scaling, res=20):
import cplot
import meshio
import meshzoo
points, cells = meshzoo.icosa_sphere(res)
evaluator = EvalCartesian(points.T, scaling, complex_valued=True)
meshes = []
for L, level in enumerate(itertools.islice(evaluator, n)):
for k, vals in enumerate(level):
> srgb1_vals = cplot.get_srgb1(vals, colorspace="cam16")
E TypeError: get_srgb1() got an unexpected keyword argument 'colorspace'
tmp_install/usr/lib/python3.10/site-packages/orthopy/u3/tools.py:39: TypeError
================================================================================= warnings summary ==================================================================================
tests/test_cn.py::test_show_tree[2]
tests/test_cn.py::test_show_tree[2]
/tmp/makepkg/python-orthopy/src/orthopy-0.9.5/tmp_install/usr/lib/python3.10/site-packages/orthopy/cn/tools.py:73: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
plt.colorbar()
tests/test_enr2.py::test_show_tree[2]
tests/test_enr2.py::test_show_tree[2]
/tmp/makepkg/python-orthopy/src/orthopy-0.9.5/tmp_install/usr/lib/python3.10/site-packages/orthopy/enr2/tools.py:80: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
plt.colorbar()
tests/test_t2.py::test_show_tree
tests/test_t2.py::test_show_tree
/tmp/makepkg/python-orthopy/src/orthopy-0.9.5/tmp_install/usr/lib/python3.10/site-packages/orthopy/t2/tools.py:112: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
plt.colorbar()
tests/test_s2/test_xu.py::test_show[degrees0]
tests/test_s2/test_xu.py::test_show[degrees0]
tests/test_s2/test_zernike.py::test_show[degrees0]
tests/test_s2/test_zernike2.py::test_show[degrees0]
/tmp/makepkg/python-orthopy/src/orthopy-0.9.5/tmp_install/usr/lib/python3.10/site-packages/orthopy/s2/tools.py:32: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
plt.colorbar()
tests/test_s2/test_xu.py::test_show_tree[2]
tests/test_s2/test_xu.py::test_show_tree[2]
tests/test_s2/test_zernike.py::test_show_tree[2]
tests/test_s2/test_zernike.py::test_show_tree[2]
tests/test_s2/test_zernike2.py::test_show_tree[2]
tests/test_s2/test_zernike2.py::test_show_tree[2]
/tmp/makepkg/python-orthopy/src/orthopy-0.9.5/tmp_install/usr/lib/python3.10/site-packages/orthopy/s2/tools.py:108: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
plt.colorbar()
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================== short test summary info ==============================================================================
FAILED README.md::line 246
FAILED tests/test_u3.py::test_write_single - TypeError: get_srgb1() got an unexpected keyword argument 'colorspace'
FAILED tests/test_u3.py::test_write_tree - TypeError: get_srgb1() got an unexpected keyword argument 'colorspace'
========================================================= 3 failed, 237 passed, 10 skipped, 16 warnings in 65.79s (0:01:05) =========================================================
I have a doubt about the inputs/outputs of the software. When I write:
x = np.linspace(-1,1,101)
evaluator = orthopy.c1.legendre.Eval(x, "classical")
for _ in range(5):
print(next(evaluator))
what I get is the function legendre evaluated at x.
However, when I write:
x = [0.1, -0.3]
evaluator = orthopy.s2.zernike.Eval(x, "normal")
for _ in range(5):
print(next(evaluator))
What am I getting here?
More details by Meurant (http://www.math.hkbu.edu.hk/ICM/LecturesAndSeminars/08OctMaterials/2/Slide2.pdf).
import orthopy
orthopy.c1.jacobi.show(5, "normal", 0.0, 0.0)
gives,
ModuleNotFoundError: No module named 'matplotx'
matplotx is not installed by default when installing orthopy.
Section 5.4 in
Orthogonal polynomials of several variables
Y. Xu, 2017,
https://arxiv.org/pdf/1701.02709.pdf.
This will allow for faster computation in numpy. Depends on sympy/sympy#13618.
Explicit polynomial integration helps, see, e.g., the e1r tests.
The polynomials generated by orthopy are not in accordance to the formal definition of the zernikes.
For example, $Z_{1}^{1} $ should be $2 \rho \cos \phi $ but the orthopy generated polynomial looks like
This is an issue with all polynomials with azimuthal degree
An easy fix could be multiplying every output polynomial where $m > 0 $ by $-1 $ where $m $ can be calculated from the OSA/ANSI index $j $ (which I believe to be self.L
in the zernike.py) by
n = int(sqrt(2*j+1) - 0.5)
m = int(2*j - n*(n+2))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.