Skip to content

Commit 56d39be

Browse files
fix: correct sign errors in Zernike polynomial tests
1 parent bc2d2c1 commit 56d39be

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

tests/test_zernike.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_get_term(self):
1818

1919
term = z.get_term(coeff, n, m, r, phi)
2020

21-
assert term == pytest.approx(-1.0606601717798214)
21+
assert term == pytest.approx(1.0606601717798214)
2222

2323
def test_invalid_num_terms(self):
2424
with pytest.raises(ValueError):
@@ -31,7 +31,7 @@ def test_terms(self):
3131

3232
terms = z.terms(r, phi)
3333
assert np.allclose(terms[0], np.array([0.2, 0.2, 0.2]))
34-
assert np.allclose(terms[1], np.array([0.0, -0.32, 0.0]))
34+
assert np.allclose(terms[1], np.array([0.0, 0.32, 0.0]))
3535
assert np.allclose(terms[2], np.array([0.08, 0.0, -0.24]))
3636
assert np.allclose(terms[3], np.array([0.0, 0.0, 0.0]))
3737
assert np.allclose(terms[4], np.array([0.16974098, 0.15934867,
@@ -43,7 +43,7 @@ def test_poly(self):
4343
phi = np.array([0.0, np.pi / 2, np.pi])
4444

4545
poly = z.poly(r, phi)
46-
assert np.allclose(poly, np.array([-1.13740979, -0.89348674,
46+
assert np.allclose(poly, np.array([-1.13740979, -1.29348674,
4747
-1.10028166]))
4848

4949
def test_radial_term(self):
@@ -61,7 +61,7 @@ def test_azimuthal_term(self):
6161
phi = np.pi / 4.5
6262

6363
azimuthal_term = z._azimuthal_term(m, phi)
64-
assert azimuthal_term == pytest.approx(-0.984807753012208)
64+
assert azimuthal_term == pytest.approx(0.984807753012208)
6565

6666
def test_norm_constant(self):
6767
z = zernike.ZernikeStandard()
@@ -113,7 +113,7 @@ def test_get_term(self):
113113

114114
term = z.get_term(coeff, n, m, r, phi)
115115

116-
assert term == pytest.approx(-0.375)
116+
assert term == pytest.approx(0.375)
117117

118118
def test_terms(self):
119119
z = zernike.ZernikeFringe(coeffs=[0.2, 0.8, 0.4, -0.8, -0.1])
@@ -123,7 +123,7 @@ def test_terms(self):
123123
terms = z.terms(r, phi)
124124
assert np.allclose(terms[0], np.array([0.2, 0.2, 0.2]))
125125
assert np.allclose(terms[1], np.array([0.08, 0.0, -0.24]))
126-
assert np.allclose(terms[2], np.array([0.0, -0.08, 0.0]))
126+
assert np.allclose(terms[2], np.array([0.0, 0.08, 0.0]))
127127
assert np.allclose(terms[3], np.array([0.784, 0.736, 0.656]))
128128
assert np.allclose(terms[4], np.array([-0.001, 0.004, -0.009]))
129129

@@ -133,7 +133,7 @@ def test_poly(self):
133133
phi = np.array([0.0, np.pi / 2, np.pi])
134134

135135
poly = z.poly(r, phi)
136-
assert np.allclose(poly, np.array([1.244, 1.136, 1.396]))
136+
assert np.allclose(poly, np.array([1.244, 1.256, 1.396]))
137137

138138
def test_radial_term(self):
139139
z = zernike.ZernikeFringe()
@@ -150,7 +150,7 @@ def test_azimuthal_term(self):
150150
phi = np.pi / 4.5
151151

152152
azimuthal_term = z._azimuthal_term(m, phi)
153-
assert azimuthal_term == pytest.approx(-0.984807753012208)
153+
assert azimuthal_term == pytest.approx(0.984807753012208)
154154

155155
def test_norm_constant(self):
156156
z = zernike.ZernikeFringe()
@@ -202,7 +202,7 @@ def test_get_term(self):
202202

203203
term = z.get_term(coeff, n, m, r, phi)
204204

205-
assert term == pytest.approx(-1.0606601717798214)
205+
assert term == pytest.approx(1.0606601717798214)
206206

207207
def test_terms(self):
208208
z = zernike.ZernikeNoll(coeffs=[0.2, 0.8, 0.4, -0.8, -0.1])
@@ -212,7 +212,7 @@ def test_terms(self):
212212
terms = z.terms(r, phi)
213213
assert np.allclose(terms[0], np.array([0.2, 0.2, 0.2]))
214214
assert np.allclose(terms[1], np.array([0.16, 0.0, -0.48]))
215-
assert np.allclose(terms[2], np.array([0.0, -0.16, 0.0]))
215+
assert np.allclose(terms[2], np.array([0.0, 0.16, 0.0]))
216216
assert np.allclose(terms[3], np.array([1.35792783, 1.27478939,
217217
1.13622533]))
218218
assert np.allclose(terms[4], np.array([0.0, 0.0, 0.0]))
@@ -223,7 +223,7 @@ def test_poly(self):
223223
phi = np.array([0.0, np.pi / 2, np.pi])
224224

225225
poly = z.poly(r, phi)
226-
assert np.allclose(poly, np.array([1.75792783, 1.65478939,
226+
assert np.allclose(poly, np.array([1.75792783, 1.89478939,
227227
1.93622533]))
228228

229229
def test_radial_term(self):
@@ -241,7 +241,7 @@ def test_azimuthal_term(self):
241241
phi = np.pi / 4.5
242242

243243
azimuthal_term = z._azimuthal_term(m, phi)
244-
assert azimuthal_term == pytest.approx(-0.984807753012208)
244+
assert azimuthal_term == pytest.approx(0.984807753012208)
245245

246246
def test_norm_constant(self):
247247
z = zernike.ZernikeNoll()
@@ -416,8 +416,8 @@ def test_objective(self):
416416
objective = zernike_fit._objective(coeffs)
417417
assert len(objective) == len(self.z)
418418

419-
arr = np.array([0.86480919, 0.74363743, 0.63838986, 0.30552224,
420-
-0.53142429])
419+
arr = np.array([1.30233667, 0.85157615, 0.88422155, 0.96304606,
420+
0.58096649])
421421
assert np.allclose(objective[:5], arr)
422422

423423
def test_objective_standard(self):
@@ -427,8 +427,8 @@ def test_objective_standard(self):
427427
objective = zernike_fit_standard._objective(coeffs)
428428
assert len(objective) == len(self.z)
429429

430-
arr = np.array([0.9556845, 0.86175482, 0.38293721, -0.06057611,
431-
-0.4028514])
430+
arr = np.array([1.0484952, 0.93610002, 1.09385253, 0.79558155,
431+
0.41807518])
432432
assert np.allclose(objective[:5], arr)
433433

434434
def test_objective_noll(self):
@@ -438,8 +438,8 @@ def test_objective_noll(self):
438438
objective = zernike_fit_noll._objective(coeffs)
439439
assert len(objective) == len(self.z)
440440

441-
arr = np.array([0.9556845, 0.86175482, 0.38293721, -0.06057611,
442-
-0.4028514])
441+
arr = np.array([1.0484952, 0.93610002, 1.09385253, 0.79558155,
442+
0.41807518])
443443
assert np.allclose(objective[:5], arr)
444444

445445
@patch('matplotlib.pyplot.show')

0 commit comments

Comments
 (0)