Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-7320

Modify ip_diffim to support pytest

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

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

        Attachments

          Issue Links

            Activity

            Hide
            fred3m 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
            

            Show
            fred3m 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
            Parejkoj 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
            Parejkoj 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
            fred3m 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
            fred3m 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
            Parejkoj 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.

            Show
            Parejkoj 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
            fred3m Fred Moolekamp added a comment -

            Show
            fred3m Fred Moolekamp added a comment -

              People

              • Assignee:
                fred3m Fred Moolekamp
                Reporter:
                fred3m Fred Moolekamp
                Reviewers:
                John Parejko
                Watchers:
                Fred Moolekamp, John Parejko, Tim Jenness
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel