Skip to content

Commit

Permalink
Merge pull request #44 from lsst/tickets/DM-42582
Browse files Browse the repository at this point in the history
DM-42582: Fix deprecated poly1d.
  • Loading branch information
ktlim committed Jan 22, 2024
2 parents 44018dc + 3feb9c3 commit e79ae78
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/test_hermiteTransformMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ def setUp(self):

@staticmethod
def ht(n):
"""return a scipy poly1d for the nth 'alternate' Hermite polynomial (i.e. Hermite polynomial
with shapeley normalization)"""
return (scipy.poly1d([(2**n * np.pi**0.5 * scipy.special.gamma(n+1))**(-0.5)])
* scipy.special.hermite(n))
"""return a numpy Polynomial for the nth 'alternate' Hermite polynomial
(i.e. Hermite polynomial with shapelet normalization)"""
hermite = scipy.special.hermite(n)
# scipy currently returns an np.poly1d; convert it if necessary
if not isinstance(hermite, np.polynomial.Polynomial):
hermite = np.polynomial.Polynomial(hermite.coef[::-1])
return (2**n * np.pi**0.5 * scipy.special.gamma(n+1))**(-0.5) * hermite

def testCoefficientMatrices(self):
coeff = self.htm.getCoefficientMatrix()
Expand All @@ -65,7 +68,7 @@ def testCoefficientsAgainstHermite(self):
coeff = self.htm.getCoefficientMatrix()
for n in range(0, self.order+1):
poly = self.ht(n)
self.assertFloatsAlmostEqual(coeff[n, :n+1], poly.c[::-1], atol=1E-15)
self.assertFloatsAlmostEqual(coeff[n, :n+1], poly.coef, atol=1E-15)

@unittest.skipIf(scipy is None, "Test requires SciPy")
def testTransformMatrix(self):
Expand Down

0 comments on commit e79ae78

Please sign in to comment.