Skip to content

Commit da31792

Browse files
authored
Bugfix: implicit growth rule incorrectly set (#330)
`sparse=True growth=None` should se `growth=True`, but didn't this means that rules that require growth rules to be nested, i.e. `clenshaw_curtis, fejer, discrete, newton_cotes` were not benefiting fully from sparse-grid. those who set `growth` explicitly are not affected.
1 parent 193413a commit da31792

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Master Branch
22
=============
33

4+
Version 4.2.5 (2021-04-16)
5+
==========================
6+
7+
FIXED:
8+
* Bugfix: `sparse=True growth=None` should se `growth=True`, but didn't this
9+
means that rules that require growth rules to be nested, i.e.
10+
`clenshaw_curtis, fejer, discrete, newton_cotes` were not benefiting
11+
fully from sparse-grid.
12+
413
Version 4.2.4 (2021-02-23)
514
==========================
615

chaospy/quadrature/sparse_grid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def construct_sparse_grid(
7171
array([ 0.17, 0.25, -0.5 , 0.25, 0.67, 0.25, -0.5 , 0.25, 0.17])
7272
"""
7373
orders = order*numpy.ones(len(dist), dtype=int)
74+
growth = True if growth is None else growth
7475

7576
assert isinstance(dist, chaospy.Distribution), "dist must be chaospy.Distribution"
7677
dist = dist if isinstance(dist, (chaospy.J, chaospy.Iid)) else chaospy.J(dist)

docs/user_guide/quadrature.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ to the :func:`chaospy.generate_quadrature` function. For example::
8787
>>> distribution = chaospy.J(
8888
... chaospy.Uniform(0, 4), chaospy.Uniform(0, 4))
8989
>>> abscissas, weights = chaospy.generate_quadrature(
90-
... 3, distribution, sparse=True)
90+
... 2, distribution, sparse=True)
9191
>>> abscissas.round(4)
92-
array([[0., 0., 0., 1., 2., 2., 2., 2., 2., 3., 4., 4., 4.],
93-
[0., 2., 4., 2., 0., 1., 2., 3., 4., 2., 0., 2., 4.]])
92+
array([[0. , 0. , 0. , 0.5858, 2. , 2. , 2. , 2. ,
93+
2. , 3.4142, 4. , 4. , 4. ],
94+
[0. , 2. , 4. , 2. , 0. , 0.5858, 2. , 3.4142,
95+
4. , 2. , 0. , 2. , 4. ]])
9496
>>> weights.round(4)
95-
array([-0.0833, 0.2222, -0.0833, 0.4444, 0.2222, 0.4444, -1.3333,
96-
0.4444, 0.2222, 0.4444, -0.0833, 0.2222, -0.0833])
97+
array([ 0.0278, -0.0222, 0.0278, 0.2667, -0.0222, 0.2667, -0.0889,
98+
0.2667, -0.0222, 0.2667, 0.0278, -0.0222, 0.0278])
9799

98100
This compared to the full tensor-product grid::
99101

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"
44

55
[tool.poetry]
66
name = "chaospy"
7-
version = "4.2.4"
7+
version = "4.2.5"
88
description = "Numerical tool for perfroming uncertainty quantification"
99
license = "MIT"
1010
authors = ["Jonathan Feinberg"]

0 commit comments

Comments
 (0)