From 47058eb41ed447057222d3d1145046f053407ec1 Mon Sep 17 00:00:00 2001 From: xywei Date: Mon, 18 Jun 2018 19:46:20 +0800 Subject: [PATCH 01/18] Add Gauss-Legendre and Chebyshev-Gauss quadurature --- modepy/__init__.py | 3 +-- modepy/quadrature/jacobi_gauss.py | 18 +++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modepy/__init__.py b/modepy/__init__.py index 72ee409..c2587b9 100644 --- a/modepy/__init__.py +++ b/modepy/__init__.py @@ -34,8 +34,7 @@ from modepy.matrices import (vandermonde, inverse_mass_matrix, mass_matrix, modal_face_mass_matrix, nodal_face_mass_matrix) from modepy.quadrature import Quadrature, QuadratureRuleUnavailable -from modepy.quadrature.jacobi_gauss import ( - JacobiGaussQuadrature, LegendreGaussQuadrature) +from modepy.quadrature.jacobi_gauss import JacobiGaussQuadrature from modepy.quadrature.xiao_gimbutas import XiaoGimbutasSimplexQuadrature from modepy.quadrature.vioreanu_rokhlin import VioreanuRokhlinSimplexQuadrature from modepy.quadrature.grundmann_moeller import GrundmannMoellerSimplexQuadrature diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index ab268e1..115a28b 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -118,18 +118,22 @@ class JacobiGaussQuadrature(Quadrature): return nodes, weights -class LegendreGaussQuadrature(JacobiGaussQuadrature): - """An Gauss quadrature associated with weight 1. +class GaussLegendreQuadrature(JacobiGaussQuadrature): + """Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature + with α = β = 0.5. + """ - Integrates on the interval (-1,1). - The quadrature rule is exact up to degree :math:`2N+1`. + def __init__(self, N): # noqa + JacobiGaussQuadrature.__init__(self, 0.5, 0.5, N) - Inherits from :class:`modepy.Quadrature`. See there for the interface - to obtain nodes and weights. + +class ChebyshevGaussQuadrature(JacobiGaussQuadrature): + """Chebyshev-Gauss quadrature is a special case of Gauss–Jacobi quadrature + with α = β = 1. """ def __init__(self, N): # noqa - JacobiGaussQuadrature.__init__(self, 0, 0, N) + JacobiGaussQuadrature.__init__(self, 1, 1, N) def jacobi_gauss_lobatto_nodes(alpha, beta, N): # noqa -- GitLab From 798ab9421ddf7292c48d5ca59ec2cb819cd6e0ac Mon Sep 17 00:00:00 2001 From: xywei Date: Mon, 18 Jun 2018 19:54:31 +0800 Subject: [PATCH 02/18] Add Gauss-Gengenbauer quadrature --- modepy/__init__.py | 4 +++- modepy/quadrature/jacobi_gauss.py | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modepy/__init__.py b/modepy/__init__.py index c2587b9..8417bd1 100644 --- a/modepy/__init__.py +++ b/modepy/__init__.py @@ -34,7 +34,9 @@ from modepy.matrices import (vandermonde, inverse_mass_matrix, mass_matrix, modal_face_mass_matrix, nodal_face_mass_matrix) from modepy.quadrature import Quadrature, QuadratureRuleUnavailable -from modepy.quadrature.jacobi_gauss import JacobiGaussQuadrature +from modepy.quadrature.jacobi_gauss import ( + JacobiGaussQuadrature, GaussLegendreQuadrature, ChebyshevGaussQuadrature, + GaussGegenbauerQuadrature) from modepy.quadrature.xiao_gimbutas import XiaoGimbutasSimplexQuadrature from modepy.quadrature.vioreanu_rokhlin import VioreanuRokhlinSimplexQuadrature from modepy.quadrature.grundmann_moeller import GrundmannMoellerSimplexQuadrature diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 115a28b..63add78 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -136,6 +136,15 @@ class ChebyshevGaussQuadrature(JacobiGaussQuadrature): JacobiGaussQuadrature.__init__(self, 1, 1, N) +class GaussGegenbauerQuadrature(JacobiGaussQuadrature): + """Gauss-Gegenbauer quadrature is a special case of Gauss–Jacobi quadrature + with α = β. + """ + + def __init__(self, alpha, N): # noqa + JacobiGaussQuadrature.__init__(self, alpha, alpha, N) + + def jacobi_gauss_lobatto_nodes(alpha, beta, N): # noqa """Compute the Gauss-Lobatto quadrature nodes corresponding to the :class:`JacobiGaussQuadrature` -- GitLab From ad78f308f10a5cbdf10b9331574ac9c478d96414 Mon Sep 17 00:00:00 2001 From: xywei Date: Mon, 18 Jun 2018 21:29:09 +0800 Subject: [PATCH 03/18] Bug fixes --- modepy/quadrature/jacobi_gauss.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 63add78..613804a 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -120,20 +120,24 @@ class JacobiGaussQuadrature(Quadrature): class GaussLegendreQuadrature(JacobiGaussQuadrature): """Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature - with α = β = 0.5. + with α = β = 0. """ def __init__(self, N): # noqa - JacobiGaussQuadrature.__init__(self, 0.5, 0.5, N) + JacobiGaussQuadrature.__init__(self, 0, 0, N) class ChebyshevGaussQuadrature(JacobiGaussQuadrature): - """Chebyshev-Gauss quadrature is a special case of Gauss–Jacobi quadrature - with α = β = 1. + """Chebyshev-Gauss quadrature of the first/second kind are special cases + of Gauss–Jacobi quadrature with α = β = -0.5/0.5. """ - def __init__(self, N): # noqa - JacobiGaussQuadrature.__init__(self, 1, 1, N) + def __init__(self, N, kind=1): # noqa + if kind == 1: + # FIXME: division by zero + JacobiGaussQuadrature.__init__(self, -0.5, -0.5, N) + elif kind == 2: + JacobiGaussQuadrature.__init__(self, 0.5, 0.5, N) class GaussGegenbauerQuadrature(JacobiGaussQuadrature): -- GitLab From 735e85cf01c0fcec0146e0a70a8255e27581d61e Mon Sep 17 00:00:00 2001 From: xywei Date: Sat, 26 Jan 2019 20:58:58 -0600 Subject: [PATCH 04/18] Fix module interface --- modepy/__init__.py | 5 ++++- modepy/quadrature/jacobi_gauss.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modepy/__init__.py b/modepy/__init__.py index 8417bd1..02c7298 100644 --- a/modepy/__init__.py +++ b/modepy/__init__.py @@ -35,7 +35,7 @@ from modepy.matrices import (vandermonde, modal_face_mass_matrix, nodal_face_mass_matrix) from modepy.quadrature import Quadrature, QuadratureRuleUnavailable from modepy.quadrature.jacobi_gauss import ( - JacobiGaussQuadrature, GaussLegendreQuadrature, ChebyshevGaussQuadrature, + JacobiGaussQuadrature, LegendreGaussQuadrature, ChebyshevGaussQuadrature, GaussGegenbauerQuadrature) from modepy.quadrature.xiao_gimbutas import XiaoGimbutasSimplexQuadrature from modepy.quadrature.vioreanu_rokhlin import VioreanuRokhlinSimplexQuadrature @@ -43,6 +43,8 @@ from modepy.quadrature.grundmann_moeller import GrundmannMoellerSimplexQuadratur from modepy.version import VERSION_TEXT as __version__ # noqa: N811 +GaussLegendreQuadrature = LegendreGaussQuadrature + __all__ = [ "__version__", @@ -60,6 +62,7 @@ __all__ = [ "Quadrature", "QuadratureRuleUnavailable", "JacobiGaussQuadrature", "LegendreGaussQuadrature", + "GaussLegendreQuadrature", "ChebyshevGaussQuadrature", "XiaoGimbutasSimplexQuadrature", "GrundmannMoellerSimplexQuadrature", "VioreanuRokhlinSimplexQuadrature", ] diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 613804a..c04aa02 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -118,7 +118,7 @@ class JacobiGaussQuadrature(Quadrature): return nodes, weights -class GaussLegendreQuadrature(JacobiGaussQuadrature): +class LegendreGaussQuadrature(JacobiGaussQuadrature): """Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature with α = β = 0. """ -- GitLab From a14b550ba46f926ac2fa1f851b564dfa6bc2bebf Mon Sep 17 00:00:00 2001 From: xywei Date: Sat, 26 Jan 2019 21:12:41 -0600 Subject: [PATCH 05/18] Add back mis-removed docstring --- modepy/quadrature/jacobi_gauss.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index c04aa02..f5bc4d2 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -119,8 +119,16 @@ class JacobiGaussQuadrature(Quadrature): class LegendreGaussQuadrature(JacobiGaussQuadrature): - """Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature - with α = β = 0. + """An Gauss quadrature associated with weight 1. + + Integrates on the interval (-1,1). + The quadrature rule is exact up to degree :math:`2N+1`. + + Inherits from :class:`modepy.Quadrature`. See there for the interface + to obtain nodes and weights. + + (NOTE: Gauss–Legendre quadrature is a special case of Gauss–Jacobi + quadrature with α = β = 0.) """ def __init__(self, N): # noqa -- GitLab From d0771055b030054c0fa20b761f503cd3d379cd30 Mon Sep 17 00:00:00 2001 From: xywei Date: Sat, 26 Jan 2019 23:21:44 -0600 Subject: [PATCH 06/18] Document new quad rules --- doc/quadrature.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/quadrature.rst b/doc/quadrature.rst index 95d406c..4200ff0 100644 --- a/doc/quadrature.rst +++ b/doc/quadrature.rst @@ -25,6 +25,10 @@ Jacobi-Gauss quadrature in one dimension .. autoclass:: LegendreGaussQuadrature +.. autoclass:: ChebyshevGaussQuadrature + +.. autoclass:: GaussGegenbauerQuadrature + .. currentmodule:: modepy.quadrature.jacobi_gauss .. autofunction:: jacobi_gauss_lobatto_nodes -- GitLab From 3c46ed7a7922f8bb5aac993b4b2634da4ee257c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Sun, 27 Jan 2019 20:54:11 +0100 Subject: [PATCH 07/18] Add versionadded markers to new Gauss shortcuts --- modepy/quadrature/jacobi_gauss.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index f5bc4d2..4e7ac83 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -138,6 +138,8 @@ class LegendreGaussQuadrature(JacobiGaussQuadrature): class ChebyshevGaussQuadrature(JacobiGaussQuadrature): """Chebyshev-Gauss quadrature of the first/second kind are special cases of Gauss–Jacobi quadrature with α = β = -0.5/0.5. + + .. versionadded:: 2019.1 """ def __init__(self, N, kind=1): # noqa @@ -151,6 +153,8 @@ class ChebyshevGaussQuadrature(JacobiGaussQuadrature): class GaussGegenbauerQuadrature(JacobiGaussQuadrature): """Gauss-Gegenbauer quadrature is a special case of Gauss–Jacobi quadrature with α = β. + + .. versionadded:: 2019.1 """ def __init__(self, alpha, N): # noqa -- GitLab From cca1ace324f6b0abbf590d5b97da29e9893ec04c Mon Sep 17 00:00:00 2001 From: xywei Date: Tue, 27 Aug 2019 10:22:54 -0500 Subject: [PATCH 08/18] Add scipy backend to jacobi_gauss --- modepy/quadrature/jacobi_gauss.py | 38 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 4e7ac83..23dc067 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -27,11 +27,13 @@ from six.moves import range import numpy as np import numpy.linalg as la from modepy.quadrature import Quadrature +from scipy.special.orthogonal import roots_jacobi class JacobiGaussQuadrature(Quadrature): r"""An Gauss quadrature of order *N* associated with the Jacobi weight :math:`(1-x)^\alpha(1+x)^\beta`. + The sample points are the roots of the (N+1)-th degree Jacobi polynomial. Assumes :math:`\alpha,\beta > -1` with :math:`(\alpha,\beta)\not\in\{(-1/2,-1/2)\}`. @@ -42,8 +44,16 @@ class JacobiGaussQuadrature(Quadrature): Inherits from :class:`modepy.Quadrature`. See there for the interface to obtain nodes and weights. """ - def __init__(self, alpha, beta, N): # noqa - x, w = self.compute_weights_and_nodes(N, alpha, beta) + def __init__(self, alpha, beta, N, backend=None): # noqa + # default backend + if backend is None: + backend = 'builtin' + if backend == 'builtin': + x, w = self.compute_weights_and_nodes(N, alpha, beta) + elif backend== 'scipy': + x, w = roots_jacobi(N + 1, alpha, beta) + else: + raise NotImplementedError("Unsupported backend: %s" % backend) Quadrature.__init__(self, x, w) @staticmethod @@ -131,8 +141,8 @@ class LegendreGaussQuadrature(JacobiGaussQuadrature): quadrature with α = β = 0.) """ - def __init__(self, N): # noqa - JacobiGaussQuadrature.__init__(self, 0, 0, N) + def __init__(self, N, backend=None): # noqa + JacobiGaussQuadrature.__init__(self, 0, 0, N, backend) class ChebyshevGaussQuadrature(JacobiGaussQuadrature): @@ -142,12 +152,12 @@ class ChebyshevGaussQuadrature(JacobiGaussQuadrature): .. versionadded:: 2019.1 """ - def __init__(self, N, kind=1): # noqa + def __init__(self, N, kind=1, backend=None): # noqa if kind == 1: - # FIXME: division by zero - JacobiGaussQuadrature.__init__(self, -0.5, -0.5, N) + # FIXME: division by zero using built-in backend + JacobiGaussQuadrature.__init__(self, -0.5, -0.5, N, backend='scipy') elif kind == 2: - JacobiGaussQuadrature.__init__(self, 0.5, 0.5, N) + JacobiGaussQuadrature.__init__(self, 0.5, 0.5, N, backend=backend) class GaussGegenbauerQuadrature(JacobiGaussQuadrature): @@ -157,11 +167,11 @@ class GaussGegenbauerQuadrature(JacobiGaussQuadrature): .. versionadded:: 2019.1 """ - def __init__(self, alpha, N): # noqa - JacobiGaussQuadrature.__init__(self, alpha, alpha, N) + def __init__(self, alpha, N, backend=None): # noqa + JacobiGaussQuadrature.__init__(self, alpha, alpha, N, backend) -def jacobi_gauss_lobatto_nodes(alpha, beta, N): # noqa +def jacobi_gauss_lobatto_nodes(alpha, beta, N, backend=None): # noqa """Compute the Gauss-Lobatto quadrature nodes corresponding to the :class:`JacobiGaussQuadrature` with the same parameters. @@ -177,14 +187,14 @@ def jacobi_gauss_lobatto_nodes(alpha, beta, N): # noqa return x x[1:-1] = np.array( - JacobiGaussQuadrature(alpha+1, beta+1, N-2).nodes + JacobiGaussQuadrature(alpha+1, beta+1, N-2, backend).nodes ).real return x -def legendre_gauss_lobatto_nodes(N): # noqa +def legendre_gauss_lobatto_nodes(N, backend=None): # noqa """Compute the Legendre-Gauss-Lobatto quadrature nodes. Exact to degree :math:`2N-1`. """ - return jacobi_gauss_lobatto_nodes(0, 0, N) + return jacobi_gauss_lobatto_nodes(0, 0, N, backend) -- GitLab From da46bf250c11b722d606acc6f1ffca41d5c16137 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wei Date: Tue, 27 Aug 2019 17:58:31 +0200 Subject: [PATCH 09/18] Update jacobi_gauss.py --- modepy/quadrature/jacobi_gauss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 94747a6..ba1c24b 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -32,7 +32,7 @@ from scipy.special.orthogonal import roots_jacobi class JacobiGaussQuadrature(Quadrature): r"""An Gauss quadrature of order *N* associated with the - Jacobi weight :math:`(1-x)^\alpha(1+x)^\beta`. + Jacobi weight :math:`(1-x)^\alpha (1+x)^\beta`. The sample points are the roots of the (N+1)-th degree Jacobi polynomial. Assumes :math:`\alpha, \beta > -1` with -- GitLab From 1f235c15daa98ee1ad56a98bf8d83c2e4e0b3d34 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wei Date: Tue, 27 Aug 2019 17:59:28 +0200 Subject: [PATCH 10/18] Update jacobi_gauss.py --- modepy/quadrature/jacobi_gauss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index ba1c24b..60eb252 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -32,7 +32,7 @@ from scipy.special.orthogonal import roots_jacobi class JacobiGaussQuadrature(Quadrature): r"""An Gauss quadrature of order *N* associated with the - Jacobi weight :math:`(1-x)^\alpha (1+x)^\beta`. + Jacobi weight :math:`(1 - x)^\alpha (1 + x)^\beta`. The sample points are the roots of the (N+1)-th degree Jacobi polynomial. Assumes :math:`\alpha, \beta > -1` with -- GitLab From 0d09984ccc4a2ac26a40610fa1e910f813d2523b Mon Sep 17 00:00:00 2001 From: xywei Date: Tue, 27 Aug 2019 11:05:29 -0500 Subject: [PATCH 11/18] Make scipy optional --- modepy/quadrature/jacobi_gauss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 60eb252..aebefd5 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -27,7 +27,6 @@ from six.moves import range import numpy as np import numpy.linalg as la from modepy.quadrature import Quadrature -from scipy.special.orthogonal import roots_jacobi class JacobiGaussQuadrature(Quadrature): @@ -51,6 +50,7 @@ class JacobiGaussQuadrature(Quadrature): if backend == 'builtin': x, w = self.compute_weights_and_nodes(N, alpha, beta) elif backend== 'scipy': + from scipy.special.orthogonal import roots_jacobi x, w = roots_jacobi(N + 1, alpha, beta) else: raise NotImplementedError("Unsupported backend: %s" % backend) -- GitLab From 3972f7c0ea780b4479f45782e9cd1db2cb4b2b6f Mon Sep 17 00:00:00 2001 From: xywei Date: Tue, 27 Aug 2019 11:10:16 -0500 Subject: [PATCH 12/18] Document changes --- modepy/quadrature/jacobi_gauss.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index aebefd5..82f89fa 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -31,12 +31,15 @@ from modepy.quadrature import Quadrature class JacobiGaussQuadrature(Quadrature): r"""An Gauss quadrature of order *N* associated with the - Jacobi weight :math:`(1 - x)^\alpha (1 + x)^\beta`. - The sample points are the roots of the (N+1)-th degree Jacobi polynomial. - - Assumes :math:`\alpha, \beta > -1` with + Jacobi weight :math:`(1 - x)^\alpha (1 + x)^\beta`, + where :math:`\alpha, \beta > -1`. + In addition, the builtin backend assumes :math:`(\alpha, \beta) \not \in \{(-1/2, -1/2)\}`. + The sample points are the roots of the (N+1)-th degree Jacobi polynomial. + Nodes and weights can be obtained from one of the supported backends + (builtin, scipy). + Integrates on the interval :math:`(-1, 1)`. The quadrature rule is exact up to degree :math:`2N + 1`. -- GitLab From acfa329c15a0e2ceaacc3565eeee09d1e5997ccd Mon Sep 17 00:00:00 2001 From: xywei Date: Tue, 27 Aug 2019 18:50:29 -0500 Subject: [PATCH 13/18] Test scipy backend --- .gitlab-ci.yml | 8 ++++---- test/test_quadrature.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 417d83d..2072e96 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ Python 2.6: script: - py_version=2.6 - - EXTRA_INSTALL=numpy + - EXTRA_INSTALL="numpy scipy" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" tags: @@ -15,7 +15,7 @@ Python 2.6: Python 2.7: script: - py_version=2.7 - - EXTRA_INSTALL=numpy + - EXTRA_INSTALL="numpy scipy" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" tags: @@ -29,7 +29,7 @@ Python 2.7: Python 3: script: - py_version=3 - - EXTRA_INSTALL=numpy + - EXTRA_INSTALL="numpy scipy" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" tags: @@ -42,7 +42,7 @@ Python 3: Documentation: script: - - EXTRA_INSTALL="numpy" + - EXTRA_INSTALL="numpy scipy" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-docs.sh - ". ./build-docs.sh" tags: diff --git a/test/test_quadrature.py b/test/test_quadrature.py index 07ba925..5580b7b 100644 --- a/test/test_quadrature.py +++ b/test/test_quadrature.py @@ -47,11 +47,12 @@ def test_transformed_quadrature(): assert abs(result - 1) < 1.0e-9 -def test_gauss_quadrature(): +@pytest.mark.parametrize("backend", [None, "builtin", "scipy"]) +def test_gauss_quadrature(backend): from modepy.quadrature.jacobi_gauss import LegendreGaussQuadrature for s in range(9 + 1): - quad = LegendreGaussQuadrature(s) + quad = LegendreGaussQuadrature(s, backend) for deg in range(quad.exact_to + 1): def f(x): return x**deg -- GitLab From 2c3f5aea37e6082fdc3267775fa97835ccfd1cee Mon Sep 17 00:00:00 2001 From: xywei Date: Tue, 27 Aug 2019 19:05:46 -0500 Subject: [PATCH 14/18] Pin wheel version for Python 2.6 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2072e96..bd1a1fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ Python 2.6: script: - py_version=2.6 - - EXTRA_INSTALL="numpy scipy" + - EXTRA_INSTALL="numpy scipy wheel==0.29.0" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" tags: -- GitLab From 1373aedcc5e6f02f9a5f398cf986ca891efa233f Mon Sep 17 00:00:00 2001 From: xywei Date: Tue, 27 Aug 2019 19:07:31 -0500 Subject: [PATCH 15/18] Fix installation order --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bd1a1fe..4408e6d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ Python 2.6: script: - py_version=2.6 - - EXTRA_INSTALL="numpy scipy wheel==0.29.0" + - EXTRA_INSTALL="wheel==0.29.0 numpy scipy" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" tags: -- GitLab From 54426ee7ce5c75bf8d4f52a2c368b7da42be390c Mon Sep 17 00:00:00 2001 From: xywei Date: Tue, 27 Aug 2019 19:19:19 -0500 Subject: [PATCH 16/18] Skip testing scipy on Python 2.6 --- .gitlab-ci.yml | 2 +- test/test_quadrature.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4408e6d..1e4005b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ Python 2.6: script: - py_version=2.6 - - EXTRA_INSTALL="wheel==0.29.0 numpy scipy" + - EXTRA_INSTALL="numpy" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" tags: diff --git a/test/test_quadrature.py b/test/test_quadrature.py index 5580b7b..fd14ce0 100644 --- a/test/test_quadrature.py +++ b/test/test_quadrature.py @@ -47,7 +47,15 @@ def test_transformed_quadrature(): assert abs(result - 1) < 1.0e-9 -@pytest.mark.parametrize("backend", [None, "builtin", "scipy"]) +try: + import scipy # noqa +except ImportError: + BACKENDS = [None, "builtin"] +else: + BACKENDS = [None, "builtin", "scipy"] + + +@pytest.mark.parametrize("backend", BACKENDS) def test_gauss_quadrature(backend): from modepy.quadrature.jacobi_gauss import LegendreGaussQuadrature -- GitLab From 8dbe557b4a3d2e921f97deb80ec42bbefb44bc17 Mon Sep 17 00:00:00 2001 From: xywei Date: Tue, 27 Aug 2019 20:09:38 -0500 Subject: [PATCH 17/18] Remove Py2.6 CI job --- .gitlab-ci.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e4005b..b51b948 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,3 @@ -Python 2.6: - script: - - py_version=2.6 - - EXTRA_INSTALL="numpy" - - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - - ". ./build-and-test-py-project.sh" - tags: - - python2.6 - except: - - tags - artifacts: - reports: - junit: test/pytest.xml - Python 2.7: script: - py_version=2.7 -- GitLab From e28228fe827fb4ca16e25c835a2d92e0316533a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Wed, 28 Aug 2019 05:27:18 +0200 Subject: [PATCH 18/18] Tweak JacobiGaussQuadrature docs --- modepy/quadrature/jacobi_gauss.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modepy/quadrature/jacobi_gauss.py b/modepy/quadrature/jacobi_gauss.py index 82f89fa..2235983 100644 --- a/modepy/quadrature/jacobi_gauss.py +++ b/modepy/quadrature/jacobi_gauss.py @@ -33,8 +33,12 @@ class JacobiGaussQuadrature(Quadrature): r"""An Gauss quadrature of order *N* associated with the Jacobi weight :math:`(1 - x)^\alpha (1 + x)^\beta`, where :math:`\alpha, \beta > -1`. - In addition, the builtin backend assumes - :math:`(\alpha, \beta) \not \in \{(-1/2, -1/2)\}`. + + :arg backend: Either ``"builtin"`` or ``"scipy"``. + + When the ``"builtin"`` back-end is in use, there is an additional requirement + that :math:`(\alpha, \beta) \not \in \{(-1/2, -1/2)\}`. The ``"scipy"`` + backend has no such restriction. The sample points are the roots of the (N+1)-th degree Jacobi polynomial. Nodes and weights can be obtained from one of the supported backends -- GitLab