コード例 #1
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
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)
コード例 #2
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
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)
コード例 #3
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
def test_calculate():
   """
   @summary: The base class does not have the _calculate method implemented, so
                this should fail
   """
   myInstance = SingleTileLCP(M_INPUT_RASTER_NO_SOURCES, 'someCostGrid.npy', 
                              seaLevelRiseCostFn)
   myInstance.calculate()
コード例 #4
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
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)
コード例 #5
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
def test_findSourceValues():
   """
   @summary: This test checks that source values can be found for proper inputs
   """
   myInstance = SingleTileLCP(M_INPUT_RASTER, '', 
                              seaLevelRiseCostFn)
   myInstance.findSourceCells()
   assert len(myInstance.sourceCells) > 0
コード例 #6
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
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)
コード例 #7
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
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)
コード例 #8
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
def test_findSourceValues_underSeaLevel():
   """
   @summary: This test checks that things operate correctly when an input 
                surface is under sea level
   """
   myInstance = SingleTileLCP(BELOW_SEA_LEVEL_RASTER, '', 
                              seaLevelRiseCostFn)
   myInstance.findSourceCells()
   assert len(myInstance.sourceCells) == 10000
コード例 #9
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
def test_findSourceValues_noSourceValues():
   """
   @summary: This test checks that things operate correctly when an input 
                surface does not have source values in it
   """
   myInstance = SingleTileLCP(M_INPUT_RASTER_NO_SOURCES, '', 
                              seaLevelRiseCostFn)
   myInstance.findSourceCells()
   print myInstance.sourceCells
   assert len(myInstance.sourceCells) == 0
コード例 #10
0
ファイル: test_base.py プロジェクト: cjgrady/irksome-broccoli
"""
@summary: Simple test to make sure that the base single tile class works
"""
import numpy

from slr.singleTile.base import SingleTileLCP

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