Skip to content

Commit 178e95a

Browse files
authored
rename MyTestFunction to FuseFunction (#30)
1 parent e8a8125 commit 178e95a

File tree

7 files changed

+46
-46
lines changed

7 files changed

+46
-46
lines changed

fuse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
from fuse.cells import Point, Edge, polygon, make_tetrahedron, constructCellComplex
33
from fuse.groups import S1, S2, S3, D4, Z3, Z4, C3, C4, S4, A4, tri_C3, tet_edges, tet_faces, sq_edges, GroupRepresentation, PermutationSetRepresentation, get_cyc_group, get_sym_group
4-
from fuse.dof import DeltaPairing, DOF, L2Pairing, MyTestFunction, PointKernel, PolynomialKernel
4+
from fuse.dof import DeltaPairing, DOF, L2Pairing, FuseFunction, PointKernel, PolynomialKernel
55
from fuse.triples import ElementTriple, DOFGenerator, immerse
66
from fuse.traces import TrH1, TrGrad, TrHess, TrHCurl, TrHDiv
77
from fuse.tensor_products import tensor_product

fuse/dof.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __call__(self, kernel, v, cell):
3535
return v(*kernel.pt)
3636

3737
def convert_to_fiat(self, ref_el, dof, interpolant_deg):
38-
pt = dof.eval(MyTestFunction(lambda *x: x))
38+
pt = dof.eval(FuseFunction(lambda *x: x))
3939
return PointEvaluation(ref_el, pt)
4040

4141
def add_entity(self, entity):
@@ -313,7 +313,7 @@ def immerse(self, entity, attachment, trace, g):
313313
raise RuntimeError("Error: Immersing twice not supported")
314314

315315

316-
class MyTestFunction():
316+
class FuseFunction():
317317

318318
def __init__(self, eq, attach_func=None, symbols=None):
319319
self.eq = eq
@@ -339,16 +339,16 @@ def __call__(self, *x, sym=False):
339339

340340
def attach(self, attachment):
341341
if not self.attach_func:
342-
return MyTestFunction(self.eq, attach_func=attachment, symbols=self.symbols)
342+
return FuseFunction(self.eq, attach_func=attachment, symbols=self.symbols)
343343
else:
344344
old_attach = self.attach_func
345345
if self.symbols:
346-
return MyTestFunction(self.eq,
347-
attach_func=attachment(old_attach(*self.symbols)),
348-
symbols=self.symbols)
346+
return FuseFunction(self.eq,
347+
attach_func=attachment(old_attach(*self.symbols)),
348+
symbols=self.symbols)
349349
else:
350-
return MyTestFunction(self.eq,
351-
attach_func=lambda *x: attachment(old_attach(*x)))
350+
return FuseFunction(self.eq,
351+
attach_func=lambda *x: attachment(old_attach(*x)))
352352

353353
def __repr__(self):
354354
if self.attach_func:

fuse/triples.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from fuse.cells import Point, TensorProductPoint
22
from fuse.spaces.element_sobolev_spaces import ElementSobolevSpace
3-
from fuse.dof import DeltaPairing, L2Pairing, MyTestFunction, PointKernel
3+
from fuse.dof import DeltaPairing, L2Pairing, FuseFunction, PointKernel
44
from fuse.traces import Trace
55
from fuse.groups import perm_matrix_to_perm_array
66
from fuse.utils import numpy_to_str_tuple
@@ -149,7 +149,7 @@ def to_tikz(self, show=True, scale=3):
149149
tikz_commands += self.cell.to_tikz(show=False, scale=scale)
150150

151151
dofs = self.generate()
152-
identity = MyTestFunction(lambda *x: x)
152+
identity = FuseFunction(lambda *x: x)
153153
for dof in dofs:
154154
center, color = self.get_dof_info(dof)
155155
if isinstance(dof.pairing, DeltaPairing):
@@ -170,7 +170,7 @@ def plot(self, filename="temp.png"):
170170
"""
171171
Generates Matplotlib code for the element diagrams."""
172172
dofs = self.generate()
173-
identity = MyTestFunction(lambda *x: x)
173+
identity = FuseFunction(lambda *x: x)
174174

175175
if self.cell.dimension == 0:
176176
raise ValueError(" Dimension 0 cells cannot be plotted")

test/test_2d_examples_docs.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def plot_dg1_tri():
5151

5252
def test_dg_examples():
5353
dg0 = construct_dg0()
54-
test_func = MyTestFunction(lambda: 3)
54+
test_func = FuseFunction(lambda: 3)
5555

5656
for dof in dg0.generate():
5757
assert np.allclose(dof.eval(test_func), 3)
5858

5959
dg1 = construct_dg1()
6060
x = sp.Symbol("x")
61-
test_func = MyTestFunction(2*x, symbols=(x,))
61+
test_func = FuseFunction(2*x, symbols=(x,))
6262

6363
dof_vals = [-2, 2]
6464

@@ -72,7 +72,7 @@ def test_dg_examples():
7272

7373
x = sp.Symbol("x")
7474
y = sp.Symbol("y")
75-
test_func = MyTestFunction(10*x + 3*y/np.sqrt(3), symbols=(x, y))
75+
test_func = FuseFunction(10*x + 3*y/np.sqrt(3), symbols=(x, y))
7676

7777
for dof in dg1.generate():
7878
assert any(np.isclose(val, dof.eval(test_func)) for val in dof_vals)
@@ -137,7 +137,7 @@ def test_cg_examples():
137137
cg1 = construct_cg1()
138138

139139
x = sp.Symbol("x")
140-
test_func = MyTestFunction(2*x, symbols=(x,))
140+
test_func = FuseFunction(2*x, symbols=(x,))
141141

142142
val_set = set([-2, 2])
143143

@@ -149,7 +149,7 @@ def test_cg_examples():
149149

150150
x = sp.Symbol("x")
151151
y = sp.Symbol("y")
152-
test_func = MyTestFunction(sp.Matrix([10*x, 3*y/np.sqrt(3)]), symbols=(x, y))
152+
test_func = FuseFunction(sp.Matrix([10*x, 3*y/np.sqrt(3)]), symbols=(x, y))
153153

154154
dof_vals = np.array([[-10, -1], [0, 2], [10, -1],
155155
[-10/3, 1], [-20/3, 0], [10/3, 1],
@@ -196,10 +196,10 @@ def test_nd_example():
196196
x = sp.Symbol("x")
197197
y = sp.Symbol("y")
198198

199-
phi_2 = MyTestFunction(sp.Matrix([1/3 - (np.sqrt(3)/6)*y, (np.sqrt(3)/6)*x]), symbols=(x, y))
200-
phi_0 = MyTestFunction(sp.Matrix([-1/6 - (np.sqrt(3)/6)*y, (-np.sqrt(3)/6) + (np.sqrt(3)/6)*x]), symbols=(x, y))
201-
phi_1 = MyTestFunction(sp.Matrix([-1/6 - (np.sqrt(3)/6)*y,
202-
(np.sqrt(3)/6) + (np.sqrt(3)/6)*x]), symbols=(x, y))
199+
phi_2 = FuseFunction(sp.Matrix([1/3 - (np.sqrt(3)/6)*y, (np.sqrt(3)/6)*x]), symbols=(x, y))
200+
phi_0 = FuseFunction(sp.Matrix([-1/6 - (np.sqrt(3)/6)*y, (-np.sqrt(3)/6) + (np.sqrt(3)/6)*x]), symbols=(x, y))
201+
phi_1 = FuseFunction(sp.Matrix([-1/6 - (np.sqrt(3)/6)*y,
202+
(np.sqrt(3)/6) + (np.sqrt(3)/6)*x]), symbols=(x, y))
203203
basis_funcs = [phi_0, phi_1, phi_2]
204204

205205
for dof in ned.generate():
@@ -236,12 +236,12 @@ def construct_rt(tri=None):
236236
def test_rt_example():
237237
x = sp.Symbol("x")
238238
y = sp.Symbol("y")
239-
phi_2 = MyTestFunction(sp.Matrix([(np.sqrt(3)/6)*x,
240-
-1/3 + (np.sqrt(3)/6)*y]), symbols=(x, y))
241-
phi_0 = MyTestFunction(sp.Matrix([(-np.sqrt(3)/6) + (np.sqrt(3)/6)*x,
242-
1/6 + (np.sqrt(3)/6)*y]), symbols=(x, y))
243-
phi_1 = MyTestFunction(sp.Matrix([(np.sqrt(3)/6) + (np.sqrt(3)/6)*x,
244-
1/6 + (np.sqrt(3)/6)*y]), symbols=(x, y))
239+
phi_2 = FuseFunction(sp.Matrix([(np.sqrt(3)/6)*x,
240+
-1/3 + (np.sqrt(3)/6)*y]), symbols=(x, y))
241+
phi_0 = FuseFunction(sp.Matrix([(-np.sqrt(3)/6) + (np.sqrt(3)/6)*x,
242+
1/6 + (np.sqrt(3)/6)*y]), symbols=(x, y))
243+
phi_1 = FuseFunction(sp.Matrix([(np.sqrt(3)/6) + (np.sqrt(3)/6)*x,
244+
1/6 + (np.sqrt(3)/6)*y]), symbols=(x, y))
245245

246246
rt = construct_rt()
247247

@@ -282,7 +282,7 @@ def test_hermite_example():
282282
# TODO improve this test
283283
x = sp.Symbol("x")
284284
y = sp.Symbol("y")
285-
phi_0 = MyTestFunction(x**2 + 3*y**3 + 4*x*y, symbols=(x, y))
285+
phi_0 = FuseFunction(x**2 + 3*y**3 + 4*x*y, symbols=(x, y))
286286
ls = her.generate()
287287
print("num dofs ", her.num_dofs())
288288
for dof in ls:
@@ -317,7 +317,7 @@ def test_square_cg():
317317
[v_dofs, e_dofs, i_dofs])
318318
x = sp.Symbol("x")
319319
y = sp.Symbol("y")
320-
test_func = MyTestFunction(x**2 + y**2, symbols=(x, y))
320+
test_func = FuseFunction(x**2 + y**2, symbols=(x, y))
321321

322322
dof_vals = np.array([0, 1, 2])
323323
for dof in cg3.generate():
@@ -344,8 +344,8 @@ def test_rt_second_order():
344344
vecP3 = PolynomialSpace(3, set_shape=True)
345345
rt2 = ElementTriple(tri, (vecP3, CellHDiv, C0), [tri_dofs, i_dofs])
346346

347-
phi = MyTestFunction(sp.Matrix([(np.sqrt(3)/6) + (np.sqrt(3)/6)*x,
348-
1/6 + (np.sqrt(3)/6)*y]), symbols=(x, y))
347+
phi = FuseFunction(sp.Matrix([(np.sqrt(3)/6) + (np.sqrt(3)/6)*x,
348+
1/6 + (np.sqrt(3)/6)*y]), symbols=(x, y))
349349

350350
for dof in rt2.generate():
351351
dof.eval(phi)

test/test_3d_examples_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_dg1():
1313
x = sp.Symbol("x")
1414
y = sp.Symbol("y")
1515
z = sp.Symbol("z")
16-
test_func = MyTestFunction(x + y + z, symbols=(x, y, z))
16+
test_func = FuseFunction(x + y + z, symbols=(x, y, z))
1717

1818
dof_vals = [x+y+z for (x, y, z) in tetra.vertices(return_coords=True)]
1919

@@ -64,7 +64,7 @@ def test_tet_cg3():
6464
x = sp.Symbol("x")
6565
y = sp.Symbol("y")
6666
z = sp.Symbol("z")
67-
test_func = MyTestFunction(sp.Matrix([10*x, 3*y/np.sqrt(3), z*4]), symbols=(x, y, z))
67+
test_func = FuseFunction(sp.Matrix([10*x, 3*y/np.sqrt(3), z*4]), symbols=(x, y, z))
6868
cg3.plot(filename="tet_cg3.png")
6969
print(cg3.to_tikz())
7070
for dof in cg3.generate():

test/test_dofs.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_permute_rt():
5252
rt = construct_rt(cell)
5353
x = sp.Symbol("x")
5454
y = sp.Symbol("y")
55-
func = MyTestFunction(sp.Matrix([x, -1/3 + 2*y]), symbols=(x, y))
55+
func = FuseFunction(sp.Matrix([x, -1/3 + 2*y]), symbols=(x, y))
5656

5757
for dof in rt.generate():
5858
print(dof)
@@ -69,26 +69,26 @@ def test_permute_nd():
6969
nd = construct_nd(cell)
7070
x = sp.Symbol("x")
7171
y = sp.Symbol("y")
72-
# func = MyTestFunction(sp.Matrix([x, -1/3 + 2*y]), symbols=(x, y))
72+
# func = FuseFunction(sp.Matrix([x, -1/3 + 2*y]), symbols=(x, y))
7373

74-
# phi_0 = MyTestFunction(sp.Matrix([-0.333333333333333*y - 0.192450089729875, 0.333333333333333*x + 0.333333333333333]), symbols=(x, y))
75-
# phi_1 = MyTestFunction(sp.Matrix([0.333333333333333*y + 0.192450089729875, 0.333333333333333 - 0.333333333333333*x]), symbols=(x, y))
74+
# phi_0 = FuseFunction(sp.Matrix([-0.333333333333333*y - 0.192450089729875, 0.333333333333333*x + 0.333333333333333]), symbols=(x, y))
75+
# phi_1 = FuseFunction(sp.Matrix([0.333333333333333*y + 0.192450089729875, 0.333333333333333 - 0.333333333333333*x]), symbols=(x, y))
7676

7777
# # original dofs
78-
phi_2 = MyTestFunction(sp.Matrix([1/3 - (np.sqrt(3)/6)*y, (np.sqrt(3)/6)*x]), symbols=(x, y))
79-
phi_0 = MyTestFunction(sp.Matrix([-1/6 - (np.sqrt(3)/6)*y, (-np.sqrt(3)/6) + (np.sqrt(3)/6)*x]), symbols=(x, y))
80-
phi_1 = MyTestFunction(sp.Matrix([-1/6 - (np.sqrt(3)/6)*y,
81-
(np.sqrt(3)/6) + (np.sqrt(3)/6)*x]), symbols=(x, y))
78+
phi_2 = FuseFunction(sp.Matrix([1/3 - (np.sqrt(3)/6)*y, (np.sqrt(3)/6)*x]), symbols=(x, y))
79+
phi_0 = FuseFunction(sp.Matrix([-1/6 - (np.sqrt(3)/6)*y, (-np.sqrt(3)/6) + (np.sqrt(3)/6)*x]), symbols=(x, y))
80+
phi_1 = FuseFunction(sp.Matrix([-1/6 - (np.sqrt(3)/6)*y,
81+
(np.sqrt(3)/6) + (np.sqrt(3)/6)*x]), symbols=(x, y))
8282

8383
for g in nd.cell.group.members():
8484
print(g)
8585
for dof in nd.generate():
8686
print(dof, "->", dof(g), "eval p2 ", dof(g).eval(phi_2), "eval p0 ", dof(g).eval(phi_0), "eval p1 ", dof(g).eval(phi_1))
8787

8888
# reflected dofs
89-
phi_2 = MyTestFunction(sp.Matrix([0.288675134594813*y - 0.333333333333333, -0.288675134594813*x]), symbols=(x, y))
90-
phi_0 = MyTestFunction(sp.Matrix([0.288675134594813*y + 0.166666666666667, -0.288675134594813*x - 0.288675134594813]), symbols=(x, y))
91-
phi_1 = MyTestFunction(sp.Matrix([0.288675134594813*y + 0.166666666666667, 0.288675134594813 - 0.288675134594813*x]), symbols=(x, y))
89+
phi_2 = FuseFunction(sp.Matrix([0.288675134594813*y - 0.333333333333333, -0.288675134594813*x]), symbols=(x, y))
90+
phi_0 = FuseFunction(sp.Matrix([0.288675134594813*y + 0.166666666666667, -0.288675134594813*x - 0.288675134594813]), symbols=(x, y))
91+
phi_1 = FuseFunction(sp.Matrix([0.288675134594813*y + 0.166666666666667, 0.288675134594813 - 0.288675134594813*x]), symbols=(x, y))
9292
reflect = nd.cell.group.get_member([0, 1, 2])
9393
print(nd.cell.permute_entities(reflect, 1))
9494
reflect = nd.cell.group.get_member([2, 0, 1])

test/test_serialisation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def test_cg_examples():
5151
for cell in cells:
5252
triple = create_cg1(cell)
5353

54-
dofs = [d.eval(MyTestFunction(lambda *x: x)) for d in triple.generate()]
54+
dofs = [d.eval(FuseFunction(lambda *x: x)) for d in triple.generate()]
5555
converter = ElementSerialiser()
5656
encoded = converter.encode(triple)
5757
decoded = converter.decode(encoded)
5858
for d in decoded.generate():
59-
dof_val = d.eval(MyTestFunction(lambda *x: x))
59+
dof_val = d.eval(FuseFunction(lambda *x: x))
6060
assert any([np.allclose(dof_val, dof_val2) for dof_val2 in dofs])
6161

6262

0 commit comments

Comments
 (0)