def test_addSourceVector_noChange(): """ @summary: This test checks that things operate properly when adding a valid source vector that does not have a lower cost for any values """ myInstance = SingleTileLCP(M_INPUT_RASTER, 'someCostGrid.npy', seaLevelRiseCostFn) myInstance.addSourceVector(np.load(TEST_VECTOR), 2)
def test_addSourceVector_matchLength(): """ @summary: This test checks that things operate properly when adding a valid source vector """ myInstance = SingleTileLCP(M_INPUT_RASTER, 'someCostGrid.npy', seaLevelRiseCostFn) myInstance.addSourceVector(np.load(TEST_VECTOR), 1)
def test_addSourceVector_badSide(): """ @summary: This test checks that an error is thrown when asking for to add source cells from an invalid side """ myInstance = SingleTileLCP(M_INPUT_RASTER, 'someCostGrid.npy', seaLevelRiseCostFn) myInstance.addSourceVector(np.load(TEST_VECTOR), 9)
def test_addSourceVector_stretchVector(): """ @summary: This test checks that an input vector that is shorter than the side it is to be compared with is stretched to match """ myInstance = SingleTileLCP(L_INPUT_RASTER, 'someCostGrid.npy', seaLevelRiseCostFn) myInstance.addSourceVector(np.load(TEST_VECTOR), 0)
def test_addSourceVector_shrinkVector(): """ @summary: This test checks that an input vector can be used that is longer than the side it is being compared with (should be shrank) """ myInstance = SingleTileLCP(S_INPUT_RASTER, 'someCostGrid.npy', seaLevelRiseCostFn) myInstance.addSourceVector(np.load(TEST_VECTOR), 3)
if __name__ == "__main__": inFn = 'testSurface.asc' outFn = 'testOut.asc' costFn = lambda x,y,z: min(x,y) t1 = SingleTileLCP(inFn, outFn, costFn) t2 = SingleTileLCP(inFn, outFn, costFn) t3 = SingleTileLCP(inFn, outFn, costFn) t1.findSourceCells() v1 = numpy.array([5, 3, 1, 2, 5]) v2 = numpy.array([8, 3, 4, 1, 2, 4]) t2.addSourceVector(v1, 0) t3.addSourceVector(v2, 1) print "t1" print t1.sourceCells print print "t2" print t2.sourceCells print print "t3" print t3.sourceCells print