Skip to content

Commit

Permalink
Remove subTask from class/config names
Browse files Browse the repository at this point in the history
  • Loading branch information
djreiss committed Aug 26, 2017
1 parent ee27c90 commit a6c487f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion tests/testImageDecorrelation.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def _runDecorrelationTaskMapReduced(self, diffExp, mKernel):
"""
config = DecorrelateALKernelMapReduceConfig()
config.borderSizeX = config.borderSizeY = 3
config.reducerSubtask.reduceOperation = 'average'
config.reducer.reduceOperation = 'average'
task = ImageMapReduceTask(config=config)
decorrResult = task.run(diffExp, template=self.im2ex, science=self.im1ex,
psfMatchingKernel=mKernel, forceEvenSized=True)
Expand Down
60 changes: 30 additions & 30 deletions tests/testImageMapReduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import lsst.pipe.base as pipeBase

from lsst.ip.diffim.imageMapReduce import (ImageMapReduceTask, ImageMapReduceConfig,
ImageMapperSubtask, ImageMapperSubtaskConfig,
ImageReducerSubtask, ImageReducerSubtaskConfig)
ImageMapper, ImageMapperConfig,
ImageReducer, ImageReducerConfig)


def setup_module(module):
Expand Down Expand Up @@ -88,8 +88,8 @@ def getPsfSecondMoments(psfArray):
return mxx, myy


class AddAmountImageMapperSubtaskConfig(ImageMapperSubtaskConfig):
"""Configuration parameters for the AddAmountImageMapperSubtask
class AddAmountImageMapperConfig(ImageMapperConfig):
"""Configuration parameters for the AddAmountImageMapper
"""
addAmount = pexConfig.Field(
dtype=float,
Expand All @@ -98,11 +98,11 @@ class AddAmountImageMapperSubtaskConfig(ImageMapperSubtaskConfig):
)


class AddAmountImageMapperSubtask(ImageMapperSubtask):
class AddAmountImageMapper(ImageMapper):
"""Image mapper subTask that adds a constant value to the input subexposure
"""
ConfigClass = AddAmountImageMapperSubtaskConfig
_DefaultName = "ip_diffim_AddAmountImageMapperSubtask"
ConfigClass = AddAmountImageMapperConfig
_DefaultName = "ip_diffim_AddAmountImageMapper"

def run(self, subExposure, expandedSubExp, fullBBox, addNans=False, **kwargs):
"""Add `addAmount` to given `subExposure`.
Expand Down Expand Up @@ -138,18 +138,18 @@ def run(self, subExposure, expandedSubExp, fullBBox, addNans=False, **kwargs):
class AddAmountImageMapReduceConfig(ImageMapReduceConfig):
"""Configuration parameters for the AddAmountImageMapReduceTask
"""
mapperSubtask = pexConfig.ConfigurableField(
mapper = pexConfig.ConfigurableField(
doc="Mapper subtask to run on each subimage",
target=AddAmountImageMapperSubtask,
target=AddAmountImageMapper,
)


class GetMeanImageMapperSubtask(ImageMapperSubtask):
class GetMeanImageMapper(ImageMapper):
"""ImageMapper subtask that computes and returns the mean value of the
input sub-exposure
"""
ConfigClass = AddAmountImageMapperSubtaskConfig # Doesn't need its own config
_DefaultName = "ip_diffim_GetMeanImageMapperSubtask"
ConfigClass = AddAmountImageMapperConfig # Doesn't need its own config
_DefaultName = "ip_diffim_GetMeanImageMapper"

def run(self, subExposure, expandedSubExp, fullBBox, **kwargs):
"""Compute the mean of the given `subExposure`
Expand Down Expand Up @@ -180,9 +180,9 @@ def run(self, subExposure, expandedSubExp, fullBBox, **kwargs):
class GetMeanImageMapReduceConfig(ImageMapReduceConfig):
"""Configuration parameters for the GetMeanImageMapReduceTask
"""
mapperSubtask = pexConfig.ConfigurableField(
mapper = pexConfig.ConfigurableField(
doc="Mapper subtask to run on each subimage",
target=GetMeanImageMapperSubtask,
target=GetMeanImageMapper,
)


Expand Down Expand Up @@ -215,8 +215,8 @@ def _testCopySumNoOverlaps(self, reduceOp='copy', withNaNs=False):
"""
config = AddAmountImageMapReduceConfig()
task = ImageMapReduceTask(config)
config.mapperSubtask.addAmount = 5.
config.reducerSubtask.reduceOperation = reduceOp
config.mapper.addAmount = 5.
config.reducer.reduceOperation = reduceOp
newExp = task.run(self.exposure, addNans=withNaNs).exposure
newMI = newExp.getMaskedImage()
newArr = newMI.getImage().getArray()
Expand All @@ -242,9 +242,9 @@ def _testAverageWithOverlaps(self, withNaNs=False):
"""
config = AddAmountImageMapReduceConfig()
config.gridStepX = config.gridStepY = 8.
config.reducerSubtask.reduceOperation = 'average'
config.reducer.reduceOperation = 'average'
task = ImageMapReduceTask(config)
config.mapperSubtask.addAmount = 5.
config.mapper.addAmount = 5.
newExp = task.run(self.exposure, addNans=withNaNs).exposure
newMI = newExp.getMaskedImage()
newArr = newMI.getImage().getArray()
Expand Down Expand Up @@ -305,12 +305,12 @@ def _testAverageVersusCopy(self, withNaNs=False):

config = AddAmountImageMapReduceConfig()
task = ImageMapReduceTask(config)
config.mapperSubtask.addAmount = 5.
config.mapper.addAmount = 5.
newExp = task.run(exposure1, addNans=withNaNs).exposure
newMI1 = newExp.getMaskedImage()

config.gridStepX = config.gridStepY = 8.
config.reducerSubtask.reduceOperation = 'average'
config.reducer.reduceOperation = 'average'
task = ImageMapReduceTask(config)
newExp = task.run(exposure2, addNans=withNaNs).exposure
newMI2 = newExp.getMaskedImage()
Expand All @@ -330,7 +330,7 @@ def testMean(self):
'none' `reduceOperation`.
"""
config = GetMeanImageMapReduceConfig()
config.reducerSubtask.reduceOperation = 'none'
config.reducer.reduceOperation = 'none'
task = ImageMapReduceTask(config)
testExposure = self.exposure.clone()
testExposure.getMaskedImage().set(1.234)
Expand All @@ -348,7 +348,7 @@ def testCellCentroids(self):
"""
config = GetMeanImageMapReduceConfig()
config.gridStepX = config.gridStepY = 8.
config.reducerSubtask.reduceOperation = 'none'
config.reducer.reduceOperation = 'none'
config.cellCentroidsX = [i for i in np.linspace(0, 128, 50)]
config.cellCentroidsY = config.cellCentroidsX
task = ImageMapReduceTask(config)
Expand All @@ -368,7 +368,7 @@ def testCellCentroidsWrongLength(self):
len(task.boxes1) and check for ValueError.
"""
config = GetMeanImageMapReduceConfig()
config.reducerSubtask.reduceOperation = 'none'
config.reducer.reduceOperation = 'none'
config.cellCentroidsX = [i for i in np.linspace(0, 128, 50)]
config.cellCentroidsY = [i for i in np.linspace(0, 128, 50)]
task = ImageMapReduceTask(config)
Expand All @@ -386,9 +386,9 @@ def testMasks(self):
config.gridStepX = config.gridStepY = 8.
config.cellCentroidsX = [i for i in np.linspace(0, 128, 50)]
config.cellCentroidsY = config.cellCentroidsX
config.reducerSubtask.reduceOperation = 'average'
config.reducer.reduceOperation = 'average'
task = ImageMapReduceTask(config)
config.mapperSubtask.addAmount = 5.
config.mapper.addAmount = 5.
newExp = task.run(self.exposure).exposure
newMI = newExp.getMaskedImage()
newArr = newMI.getImage().getArray()
Expand All @@ -407,13 +407,13 @@ def testMasks(self):
self.assertEqual(np.sum(np.isnan(newArr)), nMasked)

def testNotNoneReduceWithNonExposureMapper(self):
"""Test that a combination of a mapperSubtask that returns a non-exposure
cannot work correctly with a reducerSubtask with reduceOperation='none'.
"""Test that a combination of a mapper that returns a non-exposure
cannot work correctly with a reducer with reduceOperation='none'.
Should raise a TypeError.
"""
config = GetMeanImageMapReduceConfig() # mapper returns a float (mean)
config.gridStepX = config.gridStepY = 8.
config.reducerSubtask.reduceOperation = 'average' # not 'none'!
config.reducer.reduceOperation = 'average' # not 'none'!
task = ImageMapReduceTask(config)
with self.assertRaises(TypeError):
task.run(self.exposure)
Expand All @@ -431,7 +431,7 @@ def testGridValidity(self):
for gstepy in range(11, 3, -4):
for gsizey in gstepy + np.array([0, 1, 2]):
config = AddAmountImageMapReduceConfig()
config.reducerSubtask.reduceOperation = reduceOp
config.reducer.reduceOperation = reduceOp
n_tests += 1
self._runGridValidity(config, gstepx, gsizex,
gstepy, gsizey, adjustGridOption,
Expand Down Expand Up @@ -461,7 +461,7 @@ def _runGridValidity(self, config, gstepx, gsizex, gstepy, gsizey,
expectedVal : `float`
float to add to exposure (to compare for testing)
"""
config.mapperSubtask.addAmount = expectedVal
config.mapper.addAmount = expectedVal
lenBoxes = [0, 0]
for scaleByFwhm in (True, False):
config.scaleByFwhm = scaleByFwhm
Expand Down
2 changes: 1 addition & 1 deletion tests/testZogy.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _testZogyDiffimMapReduced(self, inImageSpace=False, doScorr=False, **kwargs)
if inImageSpace:
config.gridStepX = config.gridStepY = 8
config.borderSizeX = config.borderSizeY = 6 # need larger border size for image-space run
config.reducerSubtask.reduceOperation = 'average'
config.reducer.reduceOperation = 'average'
task = ImageMapReduceTask(config=config)
D_mapReduced = task.run(self.im1ex, template=self.im2ex, inImageSpace=inImageSpace,
doScorr=doScorr, forceEvenSized=True, **kwargs).exposure
Expand Down

0 comments on commit a6c487f

Please sign in to comment.