# Modify ip_diffim to support pytest

XMLWordPrintable

## Details

• Type: Story
• Status: Done
• Resolution: Done
• Fix Version/s: None
• Component/s: None
• Labels:
None
• Story Points:
1
• Sprint:
DRP F16-3
• Team:
Data Release Production

## Description

This ticket is for the work of migrating the ip_diffim tests such that they run with the py.test test runner.

## Activity

Hide
Fred Moolekamp added a comment -

The skipping worked fine, but when I run all of the tests together testDipole fails in line 293: AssertionError: 1.0 != 1.008598744756823 within 2 places. Any ideas why the rounding would be less accurate in an aggregate test but when running it as a single test? Full error:

 =================================== FAILURES =================================== _____________________ DipoleAlgorithmTest.testPsfDipoleFit _____________________   self =  scaling = 100.0    def testPsfDipoleFit(self, scaling=100.):  psf, psfSum, exposure, s = createDipole(self.w, self.h, self.xc, self.yc, scaling=scaling)  source = self.measureDipole(s, exposure)  # Recreate the simultaneous joint Psf fit in python  fp = source.getFootprint()  peaks = fp.getPeaks()  speaks = [(p.getPeakValue(), p) for p in peaks]  speaks.sort()  dpeaks = [speaks[0][1], speaks[-1][1]]    negCenter = afwGeom.Point2D(dpeaks[0].getFx(), dpeaks[0].getFy())  posCenter = afwGeom.Point2D(dpeaks[1].getFx(), dpeaks[1].getFy())    fneg, negPsfSum, fpos, posPsfSum, residIm = self._makeModel(exposure, psf, fp, negCenter, posCenter)    # Should be close to the same as the inputs; as fracOffset  # gets smaller this will be worse. This works for scaling =  # 100.  self.assertAlmostEqual(1e-2*scaling, -1e-2*fneg, 2) > self.assertAlmostEqual(1e-2*scaling, 1e-2*fpos, 2) E AssertionError: 1.0 != 1.008598744756823 within 2 places   tests/testDipole.py:293: AssertionError 

Show
Fred Moolekamp added a comment - The skipping worked fine, but when I run all of the tests together testDipole fails in line 293: AssertionError: 1.0 != 1.008598744756823 within 2 places. Any ideas why the rounding would be less accurate in an aggregate test but when running it as a single test? Full error: = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = FAILURES = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = _____________________ DipoleAlgorithmTest.testPsfDipoleFit _____________________   self = <testDipole.DipoleAlgorithmTest testMethod = testPsfDipoleFit> scaling = 100.0   def testPsfDipoleFit( self , scaling = 100. ): psf, psfSum, exposure, s = createDipole( self .w, self .h, self .xc, self .yc, scaling = scaling) source = self .measureDipole(s, exposure) # Recreate the simultaneous joint Psf fit in python fp = source.getFootprint() peaks = fp.getPeaks() speaks = [(p.getPeakValue(), p) for p in peaks] speaks.sort() dpeaks = [speaks[ 0 ][ 1 ], speaks[ - 1 ][ 1 ]] negCenter = afwGeom.Point2D(dpeaks[ 0 ].getFx(), dpeaks[ 0 ].getFy()) posCenter = afwGeom.Point2D(dpeaks[ 1 ].getFx(), dpeaks[ 1 ].getFy()) fneg, negPsfSum, fpos, posPsfSum, residIm = self ._makeModel(exposure, psf, fp, negCenter, posCenter) # Should be close to the same as the inputs; as fracOffset # gets smaller this will be worse. This works for scaling = # 100. self .assertAlmostEqual( 1e - 2 * scaling, - 1e - 2 * fneg, 2 ) > self .assertAlmostEqual( 1e - 2 * scaling, 1e - 2 * fpos, 2 ) E AssertionError: 1.0 ! = 1.008598744756823 within 2 places   tests / testDipole.py: 293 : AssertionError
Hide
John Parejko added a comment -

Strange. Can you put in a print to see the individual values when you run it yourself, to compare with the aggregate failure?

Show
John Parejko added a comment - Strange. Can you put in a print to see the individual values when you run it yourself, to compare with the aggregate failure?
Hide
Fred Moolekamp added a comment -

It looks like it might have something to do with how numpy seeds are calculated. I forgot about your comment to put the numpy seed inside the setup_module and now that I did that it works. Before I made the change the values of fpos and fneg were consistently different depending on whether or not a single test was run.

Show
Fred Moolekamp added a comment - It looks like it might have something to do with how numpy seeds are calculated. I forgot about your comment to put the numpy seed inside the setup_module and now that I did that it works. Before I made the change the values of fpos and fneg were consistently different depending on whether or not a single test was run.
Hide
John Parejko added a comment -

Yes, that right there is exactly why we pre-seed with a specific value inside of setUp.

Show
John Parejko added a comment - Never forget my comments! Yes, that right there is exactly why we pre-seed with a specific value inside of setUp.
Hide
Fred Moolekamp added a comment -

Show
Fred Moolekamp added a comment -

## People

• Assignee:
Fred Moolekamp
Reporter:
Fred Moolekamp
Reviewers:
John Parejko
Watchers:
Fred Moolekamp, John Parejko, Tim Jenness