def test_river_dirs(tmp_path): """Test river with exit sides 'ne' and 'sw'.""" img_path = os.path.normpath( 'tests/integration/data/Brahma/brahma_mask_clip.tif') out_path = os.path.join(tmp_path, 'cropped.tif') geo_utils.crop_geotif(img_path, npad=10, outpath=out_path) test_ne = river('Brahmclip', out_path, os.path.join(tmp_path, 'brahma'), exit_sides='ne') test_ne.compute_network() test_ne.compute_mesh() test_ne.prune_network() # make assertions assert len(test_ne.nodes['inlets']) == 1 assert len(test_ne.nodes['outlets']) == 1 assert test_ne.exit_sides == 'ne' # test sw test_sw = river('Brahmclip', out_path, os.path.join(tmp_path, 'brahma'), exit_sides='sw') test_sw.compute_network() test_sw.compute_mesh() test_sw.prune_network() # make assertions assert len(test_sw.nodes['inlets']) == 1 assert len(test_sw.nodes['outlets']) == 1 assert test_sw.exit_sides == 'sw'
def test_river(tmp_path_factory): """Define the test river network.""" np.random.seed(1) return river( 'Brahmclip', os.path.normpath('tests/integration/data/Brahma/brahma_mask_clip.tif'), os.path.join(tmp_path_factory.mktemp('brahma')), exit_sides='ns')
def test_river(): """Define the test river network.""" np.random.seed(1) return river( 'Brahmclip', os.path.join( basepath, os.path.normpath('tests/data/Brahma/brahma_mask_clip.tif')), os.path.join(basepath, os.path.normpath('tests/results/brahma/')), exit_sides='ns')
def known_river(tmp_path_factory): """Define the known river network.""" np.random.seed(1) known_river = river( 'Brahmclip', os.path.normpath('tests/integration/data/Brahma/brahma_mask_clip.tif'), os.path.join(tmp_path_factory.mktemp('brahma')), exit_sides='ns') known_river.load_network(path=os.path.normpath( 'tests/integration/data/Brahma/Brahmclip_network.pkl')) return known_river
def known_river(): """Define the known river network.""" np.random.seed(1) known_river = river( 'Brahmclip', os.path.join( basepath, os.path.normpath('tests/data/Brahma/brahma_mask_clip.tif')), os.path.join(basepath, os.path.normpath('tests/results/brahma/')), exit_sides='ns') known_river.load_network(path=os.path.join( basepath, os.path.normpath('tests/data/Brahma/Brahmclip_network.pkl'))) return known_river
def test_river_sw(): """Test river with exit sides 'sw'.""" test_sw = river( 'Brahmclip', os.path.join( basepath, os.path.normpath('tests/data/Brahma/brahma_mask_clip.tif')), os.path.join(basepath, os.path.normpath('tests/results/brahma/')), exit_sides='sw') test_sw.compute_network() test_sw.compute_mesh() test_sw.prune_network() # make assertions assert len(test_sw.nodes['inlets']) == 1 assert len(test_sw.nodes['outlets']) == 1 assert test_sw.exit_sides == 'sw'
def test_river_ne(): """Test river with exit sides 'ne'.""" img_path = os.path.join( basepath, os.path.normpath('tests/data/Brahma/brahma_mask_clip.tif')) out_path = os.path.join( basepath, os.path.normpath('tests/results/brahma/cropped.tif')) geo_utils.crop_geotif(img_path, npad=10, outpath=out_path) test_ne = river('Brahmclip', out_path, os.path.join(basepath, os.path.normpath('tests/results/brahma/')), exit_sides='ne') test_ne.compute_network() test_ne.compute_mesh() test_ne.prune_network() # make assertions assert len(test_ne.nodes['inlets']) == 1 assert len(test_ne.nodes['outlets']) == 1 assert test_ne.exit_sides == 'ne'
def test_river_noexit(): """Raise Warning when river created without exit sides.""" with pytest.raises(Warning): river('synth_river', 'tests/data/SyntheticCycle/skeleton.tif', 'tests/results/synthetic_cycles/')