@@ -44,7 +44,7 @@ def test_empty_dop(self):
4444 ga , ex , ey , ez = Ga .build ('e*x|y|z' , g = [1 , 1 , 1 ], coords = coords )
4545 v = ga .mv ('v' , 'vector' , f = True )
4646
47- make_zero = Dop ([], ga = ga )
47+ make_zero = ga . dop ([])
4848 assert make_zero * v == 0
4949 assert make_zero * make_zero * v == 0
5050 assert (make_zero + make_zero ) * v == 0
@@ -65,8 +65,13 @@ def test_misc(self):
6565 assert laplacian .is_scalar ()
6666 assert not ga .grad .is_scalar ()
6767
68+ # test comparison
6869 assert ga .grad == ga .grad
70+ assert not (ga .grad != ga .grad )
6971 assert ga .grad != laplacian
72+ assert not (ga .grad == laplacian )
73+ assert ga .grad != object ()
74+ assert not (ga .grad == object ())
7075
7176 # inconsistent cmpflg, not clear which side the operator goes on
7277 with pytest .raises (ValueError ):
@@ -108,8 +113,7 @@ def test_shorthand(self):
108113 coords = x , y , z = symbols ('x y z' , real = True )
109114 ga , ex , ey , ez = Ga .build ('e*x|y|z' , g = [1 , 1 , 1 ], coords = coords )
110115
111- # TODO: __eq__ is broken, remove `repr` when it is fixed
112- assert repr (Sdop (x , ga = ga )) == repr (Sdop ([(S (1 ), Pdop ({x : 1 }, ga = ga ))], ga = ga ))
116+ assert Sdop (x , ga = ga ) == Sdop ([(S (1 ), Pdop ({x : 1 }, ga = ga ))], ga = ga )
113117
114118 def test_empty_sdop (self ):
115119 """ Test that sdop with zero terms is equivalent to multiplying by zero """
@@ -123,18 +127,6 @@ def test_empty_sdop(self):
123127 assert (make_zero + make_zero ) * v == 0
124128 assert (- make_zero ) * v == 0
125129
126-
127- class TestPdop (object ):
128-
129- def test_deprecation (self ):
130- coords = x , y , z = symbols ('x y z' , real = True )
131- ga , ex , ey , ez = Ga .build ('e*x|y|z' , g = [1 , 1 , 1 ], coords = coords )
132-
133- # passing `None` is a deprecate way to spell `{}`
134- with pytest .warns (DeprecationWarning ):
135- p = Pdop (None , ga = ga )
136- assert p == Pdop ({}, ga = ga )
137-
138130 def test_associativity_and_distributivity (self ):
139131 coords = x , y , z = symbols ('x y z' , real = True )
140132 ga , ex , ey , ez = Ga .build ('e*x|y|z' , g = [1 , 1 , 1 ], coords = coords )
@@ -152,3 +144,48 @@ def test_associativity_and_distributivity(self):
152144 # check multiplication is associative
153145 assert (20 * laplacian ) * v == 20 * (laplacian * v ) != 0
154146 assert (laplacian * laplacian ) * v == laplacian * (laplacian * v ) != 0
147+
148+
149+ def test_misc (self ):
150+ """ Other miscellaneous tests """
151+ coords = x , y , z = symbols ('x y z' , real = True )
152+ ga , ex , ey , ez = Ga .build ('e*x|y|z' , g = [1 , 1 , 1 ], coords = coords )
153+ laplacian = ga .sdop ((ga .grad * ga .grad ).terms )
154+ lap2 = laplacian * laplacian
155+
156+ # test comparison
157+ assert lap2 == lap2
158+ assert not (lap2 != lap2 )
159+ assert lap2 != laplacian
160+ assert not (lap2 == laplacian )
161+ assert lap2 != object ()
162+ assert not (lap2 == object ())
163+
164+
165+ class TestPdop (object ):
166+
167+ def test_deprecation (self ):
168+ coords = x , y , z = symbols ('x y z' , real = True )
169+ ga , ex , ey , ez = Ga .build ('e*x|y|z' , g = [1 , 1 , 1 ], coords = coords )
170+
171+ # passing `None` is a deprecate way to spell `{}`
172+ with pytest .warns (DeprecationWarning ):
173+ p = Pdop (None , ga = ga )
174+ assert p == Pdop ({}, ga = ga )
175+
176+ def test_misc (self ):
177+ """ Other miscellaneous tests """
178+ coords = x , y , z = symbols ('x y z' , real = True )
179+ ga , ex , ey , ez = Ga .build ('e*x|y|z' , g = [1 , 1 , 1 ], coords = coords )
180+
181+ pxa = ga .pdop ({x : 1 })
182+ pxb = ga .pdop ({x : 1 })
183+ p1 = ga .pdop ({})
184+
185+ # test comparison
186+ assert pxa == pxb
187+ assert not (pxa != pxb )
188+ assert p1 != pxa
189+ assert not (p1 == pxa )
190+ assert pxa != object ()
191+ assert not (pxa == object ())
0 commit comments