-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests for _stack_bands and deprecated stack_raster_tifs. (#241)
* added tests for _stack_bands and deprecated stack_raster_tifs. Also edited _stack_bands in spatial.py since it needed to change ValueError to Exception for except clause to be accessed. Otherwise, the specific error in the test is an AttributeError. * cleaned up imports and changed Exception to AssertionError in spatial.py stack function * Adding warning message to stack_raster_tifs deprecation test
- Loading branch information
Joe McGlinchy
authored and
Leah Wasser
committed
Feb 19, 2019
1 parent
5bc49cb
commit cdfb644
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" Tests for the _stack_bands() method """ | ||
|
||
import numpy as np | ||
import pytest | ||
import earthpy.spatial as es | ||
|
||
|
||
@pytest.fixture | ||
def b1_b2_arrs(): | ||
b1 = np.array([[6, 7, 8, 9, 10], [16, 17, 18, 19, 20]]) | ||
b2 = np.array([[1, 2, 3, 4, 5], [14, 12, 13, 14, 17]]) | ||
return b1, b2 | ||
|
||
|
||
def test__stack_bands(b1_b2_arrs): | ||
"""_stack_bands input should be of type DatasetReader.""" | ||
|
||
# Test data | ||
b1, b2 = b1_b2_arrs | ||
|
||
# Check ValueError for Dataset Reader | ||
with pytest.raises( | ||
AttributeError, match="The sources object should be Dataset Reader" | ||
): | ||
es._stack_bands([b1, b2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" Tests for the _stack_bands() method """ | ||
|
||
import numpy as np | ||
import pytest | ||
import earthpy.spatial as es | ||
|
||
|
||
@pytest.fixture | ||
def b1_b2_arrs(): | ||
b1 = np.array([[6, 7, 8, 9, 10], [16, 17, 18, 19, 20]]) | ||
b2 = np.array([[1, 2, 3, 4, 5], [14, 12, 13, 14, 17]]) | ||
return b1, b2 | ||
|
||
|
||
def test_stack_raster_tifs(b1_b2_arrs): | ||
"""stack_raster_tifs() should return a Warning.""" | ||
|
||
# Test data | ||
b1, b2 = b1_b2_arrs | ||
|
||
# Check Warning for Deprecation | ||
with pytest.raises(Warning, match="stack_raster_tifs is deprecated"): | ||
es.stack_raster_tifs([b1, b2], out_path="test.tif") |