Skip to content

Commit 51be849

Browse files
committed
Bump version
1 parent 8479a4d commit 51be849

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

shenfun/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"""
3030
#pylint: disable=wildcard-import,no-name-in-module
3131

32-
__version__ = '4.0.2'
32+
__version__ = '4.1.0'
3333
__author__ = 'Mikael Mortensen'
3434

3535
import numpy as np

shenfun/spectralbase.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1976,13 +1976,19 @@ def orderednames(self):
19761976
return ['L'+bci for bci in sorted(self['left'].keys())] + ['R'+bci for bci in sorted(self['right'].keys())]
19771977

19781978
def orderedvals(self):
1979-
return [self['left'][bci] for bci in sorted(self['left'].keys())] + [self['right'][bci] for bci in sorted(self['right'].keys())]
1979+
ls = []
1980+
for lr in ('left', 'right'):
1981+
for key in sorted(self[lr].keys()):
1982+
val = self[lr][key]
1983+
ls.append(val[1] if isinstance(val, (tuple, list)) else val)
1984+
return ls
1985+
#return [self['left'][bci] for bci in sorted(self['left'].keys())] + [self['right'][bci] for bci in sorted(self['right'].keys())]
19801986

19811987
def num_bcs(self):
19821988
return len(self.orderedvals())
19831989

19841990
def num_derivatives(self):
1985-
n = {'D': 0, 'N': 1, 'N2': 2, 'N3': 3, 'N4': 4}
1991+
n = {'D': 0, 'R': 0, 'N': 1, 'N2': 2, 'N3': 3, 'N4': 4}
19861992
num_diff = 0
19871993
for val in self.values():
19881994
for k in val:

shenfun/utilities/findbasis.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ def get_stencil_matrix(bcs, family, alpha=None, beta=None, gn=1):
4141
bcs = BoundaryConditions(bcs)
4242
bc = {'D': 0, 'N': 1, 'N2': 2, 'N3': 3, 'N4': 4}
4343
lr = {'L': 0, 'R': 1}
44+
lra = {'L': 'left', 'R': 'right'}
4445
s = []
4546
r = []
4647
for key in bcs.orderednames():
4748
k, v = key[0], key[1:]
48-
f = bnd_values(k=bc[v])[lr[k]]
49-
s.append([sp.simplify(f(n+j)) for j in range(1, 1+bcs.num_bcs())])
50-
r.append(-sp.simplify(f(n)))
49+
if v == 'R':
50+
alfa = bcs[lra[k]]['R'][0]
51+
f = [bnd_values(k=0)[lr[k]], bnd_values(k=1)[lr[k]]]
52+
s.append([sp.simplify(f[0](n+j)+alfa*f[1](n+j)) for j in range(1, 1+bcs.num_bcs())])
53+
r.append(-sp.simplify(f[0](n)+alfa*f[1](n)))
54+
else:
55+
f = bnd_values(k=bc[v])[lr[k]]
56+
s.append([sp.simplify(f(n+j)) for j in range(1, 1+bcs.num_bcs())])
57+
r.append(-sp.simplify(f(n)))
5158
A = sp.Matrix(s)
5259
b = sp.Matrix(r)
5360
M = sp.simplify(A.solve(b))
@@ -89,11 +96,17 @@ def get_bc_basis(bcs, family, alpha=None, beta=None, gn=1):
8996
def _computematrix(first):
9097
bc = {'D': 0, 'N': 1, 'N2': 2, 'N3': 3, 'N4': 4}
9198
lr = {'L': 0, 'R': 1}
99+
lra = {'L': 'left', 'R': 'right'}
92100
s = []
93101
for key in bcs.orderednames():
94102
k, v = key[0], key[1:]
95-
f = bnd_values(k=bc[v])[lr[k]]
96-
s.append([sp.simplify(f(j)) for j in range(first, first+bcs.num_bcs())])
103+
if v == 'R':
104+
alfa = bcs[lra[k]]['R'][0]
105+
f = [bnd_values(k=0)[lr[k]], bnd_values(k=1)[lr[k]]]
106+
s.append([sp.simplify(f[0](j)+alfa*f[1](j)) for j in range(first, first+bcs.num_bcs())])
107+
else:
108+
f = bnd_values(k=bc[v])[lr[k]]
109+
s.append([sp.simplify(f(j)) for j in range(first, first+bcs.num_bcs())])
97110

98111
A = sp.Matrix(s)
99112
s = sp.simplify(A.solve(sp.eye(bcs.num_bcs())).T)

0 commit comments

Comments
 (0)