Skip to content

Commit 39414d2

Browse files
committed
fixing numpoly interface
1 parent 24df1ff commit 39414d2

File tree

10 files changed

+25
-26
lines changed

10 files changed

+25
-26
lines changed

.circleci/config.yml

-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ jobs:
5555
key: deps-py38-{{ checksum "poetry.lock" }}
5656
paths:
5757
- /home/circleci/venv
58-
- run:
59-
name: "Ensure the documentation builds"
60-
command: |
61-
source /home/circleci/venv/bin/activate
62-
sphinx-build docs/ docs/.build -b html -n -v --color -T -W
6358
- run:
6459
name: "Run pytest"
6560
command: |

chaospy/basis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ def basis(start, stop=None, dim=1, cross_truncation=1., sort="G"):
4646
out = numpoly.monomial(
4747
start=start,
4848
stop=numpy.array(stop)+1,
49+
dimensions=dim,
4950
reverse="R" not in sort.upper(),
5051
graded="G" in sort.upper(),
5152
cross_truncation=cross_truncation,
52-
names=numpoly.symbols("q:%d" % dim, asarray=True),
5353
)
5454
if "I" in sort.upper():
5555
out = out[::-1]

chaospy/descriptives/conditional.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ def E_cond(poly, freeze, dist, **kws):
7171

7272
# Remove frozen coefficients, such that poly == sum(frozen*unfrozen) holds
7373
for key in unfrozen.keys:
74-
unfrozen[key] = unfrozen[key] != 0
74+
unfrozen[key] = unfrozen.values[key] != 0
7575

7676
return numpoly.sum(frozen*E(unfrozen, dist), 0)

chaospy/descriptives/expected.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ def E(poly, dist=None, **kws):
4545

4646
out = numpy.zeros(poly.shape)
4747
for idx, key in enumerate(poly.keys):
48-
out += poly[key]*moments[idx]
48+
out += poly.values[key]*moments[idx]
4949
return out

chaospy/orthogonal/cholesky.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def orth_chol(order, dist, normed=False, graded=True, reverse=True,
6969
basis = numpoly.monomial(
7070
start=1,
7171
stop=order+1,
72-
names=numpoly.variable(dim).names,
72+
dimensions=dim,
7373
graded=graded,
7474
reverse=reverse,
7575
cross_truncation=cross_truncation,

chaospy/orthogonal/gram_schmidt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def orth_gs(order, dist, normed=False, graded=True, reverse=True,
6060
basis = numpoly.monomial(
6161
0,
6262
order+1,
63-
names=numpoly.variable(2).names,
63+
dimensions=dim,
6464
graded=graded,
6565
reverse=reverse,
6666
cross_truncation=cross_truncation,

chaospy/orthogonal/lagrange.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -59,37 +59,36 @@ def lagrange_polynomial(abscissas, graded=True, reverse=True, sort=None):
5959
raise numpy.linalg.LinAlgError(
6060
"Lagrange abscissas resulted in invertible matrix")
6161

62-
names = numpoly.variable(dim).names
6362
vec = numpoly.monomial(
64-
0, order+1, names=names, graded=graded, reverse=reverse)[:size]
63+
0, order+1, dimensions=dim, graded=graded, reverse=reverse)[:size]
6564

6665
coeffs = numpy.zeros((size, size))
6766

6867
if size == 1:
69-
out = numpoly.monomial(
70-
0, 1, names=names, graded=graded, reverse=reverse)*abscissas.item()
68+
out = numpoly.monomial(0, 1, dimensions=dim, graded=graded,
69+
reverse=reverse)*abscissas.item()
7170

7271
elif size == 2:
7372
coeffs = numpy.linalg.inv(matrix)
7473
out = numpoly.sum(vec*(coeffs.T), 1)
7574

7675
else:
7776
for i in range(size):
78-
if i%2 != 0:
77+
if i % 2 != 0:
7978
k = 1
8079
else:
81-
k=0
80+
k = 0
8281
for j in range(size):
83-
if k%2 == 0:
82+
if k % 2 == 0:
8483
coeffs[i, j] += numpy.linalg.det(matrix[1:, 1:])
8584
else:
86-
if size%2 == 0:
85+
if size % 2 == 0:
8786
coeffs[i, j] += -numpy.linalg.det(matrix[1:, 1:])
8887
else:
8988
coeffs[i, j] += numpy.linalg.det(matrix[1:, 1:])
90-
matrix = numpy.roll(matrix, -1, axis=0)
89+
matrix = numpy.roll(matrix, -1, axis=0)
9190
k += 1
92-
matrix = numpy.roll(matrix, -1, axis=1)
91+
matrix = numpy.roll(matrix, -1, axis=1)
9392
coeffs /= det
9493
out = numpoly.sum(vec*(coeffs.T), 1)
9594

chaospy/prange.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ def prange(N=1, dim=1):
2525
polynomial([1, q2, q2**2, q2**3])
2626
"""
2727
logger = logging.getLogger(__name__)
28-
logger.warning("chaospy.prange is deprecated; use chaospy.monomial instead")
29-
return numpoly.monomial(N, names=["q%d" % (dim-1)])
28+
logger.warning(
29+
"chaospy.prange is deprecated; use chaospy.monomial instead")
30+
out = numpoly.monomial(N)
31+
if dim > 1:
32+
out = numpoly.call(
33+
out, kwargs={out.names[0]: numpoly.variable(dim)[-1]})
34+
return out

chaospy/quadrature/recurrence/stieltjes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def analytical_stieljes(order, dist, normed=False):
145145

146146
norms = numpy.cumprod(coeffs[1], 1)
147147
if normed:
148-
orth = numpoly.true_divide(orth, numpy.sqrt(norms))
148+
orth = numpoly.polynomial(orth)/numpy.sqrt(norms)
149149
norms **= 0
150150

151151
return coeffs, orth, norms

chaospy/saltelli.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def Sens_m_sample(poly, dist, samples, rule="random"):
103103
104104
Examples:
105105
>>> dist = chaospy.Iid(chaospy.Uniform(), 2)
106-
>>> poly = chaospy.monomial(2, 3, names=2, reverse=False)
106+
>>> poly = chaospy.monomial(2, 3, dimensions=2, reverse=False)
107107
>>> poly
108108
polynomial([q0**2, q0*q1, q1**2])
109109
>>> Sens_m_sample(poly, dist, 10000, rule="hammersley").round(4)
@@ -157,7 +157,7 @@ def Sens_m2_sample(poly, dist, samples, rule="random"):
157157
158158
Examples:
159159
>>> dist = chaospy.Iid(chaospy.Uniform(), 2)
160-
>>> poly = chaospy.monomial(2, 3, names=2, reverse=False)
160+
>>> poly = chaospy.monomial(2, 3, dimensions=2, reverse=False)
161161
>>> poly
162162
polynomial([q0**2, q0*q1, q1**2])
163163
>>> Sens_m2_sample(poly, dist, 10000, rule="halton").round(4)
@@ -236,7 +236,7 @@ def Sens_t_sample(poly, dist, samples, rule="random"):
236236
237237
Examples:
238238
>>> dist = chaospy.Iid(chaospy.Uniform(0, 1), 2)
239-
>>> poly = chaospy.monomial(2, 3, names=2, reverse=False)
239+
>>> poly = chaospy.monomial(2, 3, dimensions=2, reverse=False)
240240
>>> poly
241241
polynomial([q0**2, q0*q1, q1**2])
242242
>>> Sens_t_sample(poly, dist, 10000, rule="halton").round(4)

0 commit comments

Comments
 (0)