Skip to content

Commit

Permalink
Add two tests that shows the segfault
Browse files Browse the repository at this point in the history
...one for PolyMap, one for ChebyMap.
  • Loading branch information
r-owen committed May 10, 2017
1 parent a22bfa2 commit 4d954d8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test_chebyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,38 @@ def test_normalize(self):
self.assertAlmostEqual(normAxis.min(), -1)
self.assertAlmostEqual(normAxis.max(), 1)

def test_ChebyMapDM10496(self):
"""Test for a segfault when simplifying a SeriesMap
We saw an intermittent segfault when simplifying a SeriesMap
consisting of the inverse of PolyMap with 2 inputs and one output
followed by its inverse (which should simplify to a UnitMap
with one input and one output). David Berry fixed this bug in AST
2017-05-10.
I tried this test on an older version of astshim and found that it
triggering a segfault nearly every time.
"""
coeff_f = np.array([
[-1.1, 1, 2, 0],
[1.3, 1, 3, 1],
])
coeff_i = np.array([
[1.6, 1, 3],
[-3.6, 2, 1],
])
lbnd_f = [-2.0, -2.5]
ubnd_f = [1.5, -0.5]
lbnd_i = [-3.0]
ubnd_i = [-1.0]

for i in range(1000):
amap = astshim.ChebyMap(coeff_f, coeff_i, lbnd_f, ubnd_f, lbnd_i, ubnd_i)
amapinv = amap.getInverse()
cmp2 = amap.of(amapinv)
result = cmp2.simplify()
self.assertIsInstance(result, astshim.UnitMap)


if __name__ == "__main__":
unittest.main()
28 changes: 28 additions & 0 deletions tests/test_polyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,34 @@ def test_PolyMapPolyMapUnivertible(self):
# so no inverse is possible
pm.polyTran(False, 1e-3, 1e-3, 10, [-1.0], [2.5])

def test_PolyMapDM10496(self):
"""Test for a segfault when simplifying a SeriesMap
We saw an intermittent segfault when simplifying a SeriesMap
consisting of the inverse of PolyMap with 2 inputs and one output
followed by its inverse (which should simplify to a UnitMap
with one input and one output). David Berry fixed this bug in AST
2017-05-10.
I tried this test on an older version of astshim and found that it
triggering a segfault nearly every time.
"""
coeff_f = np.array([
[-1.1, 1, 2, 0],
[1.3, 1, 3, 1],
])
coeff_i = np.array([
[1.6, 1, 3],
[-3.6, 2, 1],
])

for i in range(1000):
amap = astshim.PolyMap(coeff_f, coeff_i)
amapinv = amap.getInverse()
cmp2 = amap.of(amapinv)
result = cmp2.simplify()
self.assertIsInstance(result, astshim.UnitMap)


if __name__ == "__main__":
unittest.main()

0 comments on commit 4d954d8

Please sign in to comment.