Skip to content

Commit

Permalink
fixed test to reflect expected values based on changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KMarkert committed Mar 31, 2021
1 parent a64a54d commit 6392180
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hydrafloods/tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_landsat7(self):

def test_modis(self):
modis = hf.Modis(TEST_REGION, TEST_START_TIME, TEST_END_TIME)
assert modis.n_images == 6
assert modis.n_images == 7

def test_viirs(self):
viirs = hf.Viirs(TEST_REGION, TEST_START_TIME, TEST_END_TIME)
Expand Down
19 changes: 14 additions & 5 deletions hydrafloods/tests/test_thresholds.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,23 @@ def test_edge_otsu(self):

def test_bmax_otsu(self):
kwargs = dict(initial_threshold=-16, scale=PROCESS_SCALE, return_threshold=True)
threshold = (
threshold1 = (
hf.bmax_otsu(S1, **kwargs)
.reduceRegion(ee.Reducer.mean(), GEOM, REDUCTION_SCALE)
.getInfo()
)
threshold = {k: round(v, 6) for k, v in threshold.items()}
threshold1 = {k: round(v, 6) for k, v in threshold1.items()}

thresh1_expected = {"constant": -13.950876}

threshold2 = (
hf.bmax_otsu(S1, **{**kwargs,**{"iters":3}})
.reduceRegion(ee.Reducer.mean(), GEOM, REDUCTION_SCALE)
.getInfo()
)
threshold2 = {k: round(v, 6) for k, v in threshold1.items()}

thresh_expected = {"constant": -14.207951}
thresh2_expected = {"constant": -13.950876}

kwargs["return_threshold"] = False
water = (
Expand All @@ -67,7 +76,7 @@ def test_bmax_otsu(self):

water_expected = {"water": 0}

assert (threshold == thresh_expected) and (water == water_expected)
assert (threshold1 == thresh1_expected) and (threshold2 == thresh2_expected) and (water == water_expected)

def test_kmeans_extent(self):
hand = ee.Image("MERIT/Hydro/v1_0_1").select("hnd")
Expand Down Expand Up @@ -98,7 +107,7 @@ def test_multidim_semisupervised(self):
).getInfo()
water_proba = {k: round(v, 6) for k, v in water_proba.items()}

proba_expected = {"water_proba": 0.006705}
proba_expected = {"water_proba": 0.006551}

multidim = hf.multidim_semisupervised(
index_img,
Expand Down

0 comments on commit 6392180

Please sign in to comment.