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-12656: Fix some new flake8 warnings #102

Merged
merged 3 commits into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions python/lsst/meas/base/noiseReplacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(self, config, exposure, footprints, noiseImage=None, exposureId=Non
plane = mask.getMaskPlane(maskname)
if self.log:
self.log.debug('Mask plane "%s" already existed', maskname)
except:
except Exception:
# if not, add it; we should delete it when done.
plane = mask.addMaskPlane(maskname)
self.removeplanes.append(maskname)
Expand Down Expand Up @@ -155,11 +155,11 @@ def __init__(self, config, exposure, footprints, noiseImage=None, exposureId=Non
elif fp[0] == 0:
self.heavies[id] = afwDet.makeHeavyFootprint(fp[1], mi)

### FIXME: the heavy footprint includes the mask
### and variance planes, which we shouldn't need
### (I don't think we ever want to modify them in
### the input image). Copying them around is
### wasteful.
# ## FIXME: the heavy footprint includes the mask
# ## and variance planes, which we shouldn't need
# ## (I don't think we ever want to modify them in
# ## the input image). Copying them around is
# ## wasteful.

# We now create a noise HeavyFootprint for each source with has a heavy footprint.
# We'll put the noise footprints in a dict heavyNoise = {id:heavyNoiseFootprint}
Expand Down Expand Up @@ -281,7 +281,7 @@ def getNoiseGenerator(self, exposure, noiseImage, noiseMeanVar, exposureId=None)
self.log.debug('Using passed-in noise mean = %g, variance = %g -> stdev %g',
noiseMean, noiseVar, noiseStd)
return FixedGaussianNoiseGenerator(noiseMean, noiseStd, rand=rand)
except:
except Exception:
if self.log:
self.log.debug('Failed to cast passed-in noiseMeanVar to floats: %s',
str(noiseMeanVar))
Expand All @@ -300,7 +300,7 @@ def getNoiseGenerator(self, exposure, noiseImage, noiseMeanVar, exposureId=None)
self.log.debug('Using noise variance = (BGMEAN = %g) from exposure metadata',
bgMean)
return FixedGaussianNoiseGenerator(offset, noiseStd, rand=rand)
except:
except Exception:
if self.log:
self.log.debug('Failed to get BGMEAN from exposure metadata')

Expand Down
2 changes: 1 addition & 1 deletion tests/test_PluginLogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def testLoggingCppPlugin(self):
# This call throws an error, so be prepared for it
try:
task.run(cat, exposure)
except:
except Exception:
pass
directLog(log, None)
# direct back to console, closing log files
Expand Down
28 changes: 14 additions & 14 deletions tests/test_ShapeUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ def testIdentity(self):
def testVsTransform(self):
# Transforming an ellipse by multiplying by the matrix should be
# equivalent to calling its transform() method.
l = lsst.afw.geom.LinearTransform.makeRotation(lsst.afw.geom.Angle(numpy.random.random()))
lt = lsst.afw.geom.LinearTransform.makeRotation(lsst.afw.geom.Angle(numpy.random.random()))
e = lsst.afw.geom.ellipses.Quadrupole(numpy.random.random(), numpy.random.random(),
numpy.random.random())
numpy.testing.assert_array_almost_equal(numpy.dot(lsst.meas.base.makeShapeTransformMatrix(l),
numpy.testing.assert_array_almost_equal(numpy.dot(lsst.meas.base.makeShapeTransformMatrix(lt),
e.getParameterVector()),
e.transform(l).getParameterVector())
e.transform(lt).getParameterVector())

def testVales(self):
# Test that the analytically-derived correct values are computed
l = lsst.afw.geom.LinearTransform(numpy.random.random((2, 2)))
m = lsst.meas.base.makeShapeTransformMatrix(l)
lt = lsst.afw.geom.LinearTransform(numpy.random.random((2, 2)))
m = lsst.meas.base.makeShapeTransformMatrix(lt)

self.assertEqual(m[0, 0], l[0, 0]*l[0, 0])
self.assertEqual(m[0, 1], l[0, 1]*l[0, 1])
self.assertEqual(m[0, 2], 2*l[0, 0]*l[0, 1])
self.assertEqual(m[0, 0], lt[0, 0]*lt[0, 0])
self.assertEqual(m[0, 1], lt[0, 1]*lt[0, 1])
self.assertEqual(m[0, 2], 2*lt[0, 0]*lt[0, 1])

self.assertEqual(m[1, 0], l[1, 0]*l[1, 0])
self.assertEqual(m[1, 1], l[1, 1]*l[1, 1])
self.assertEqual(m[1, 2], 2*l[1, 0]*l[1, 1])
self.assertEqual(m[1, 0], lt[1, 0]*lt[1, 0])
self.assertEqual(m[1, 1], lt[1, 1]*lt[1, 1])
self.assertEqual(m[1, 2], 2*lt[1, 0]*lt[1, 1])

self.assertEqual(m[2, 0], l[0, 0]*l[1, 0])
self.assertEqual(m[2, 1], l[0, 1]*l[1, 1])
self.assertEqual(m[2, 2], l[0, 0]*l[1, 1] + l[0, 1]*l[1, 0])
self.assertEqual(m[2, 0], lt[0, 0]*lt[1, 0])
self.assertEqual(m[2, 1], lt[0, 1]*lt[1, 1])
self.assertEqual(m[2, 2], lt[0, 0]*lt[1, 1] + lt[0, 1]*lt[1, 0])


class TestMemory(lsst.utils.tests.MemoryTestCase):
Expand Down