Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-42582: Fix deprecated poly1d. #44

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions tests/test_hermiteTransformMatrix.py
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