def test_simple_case(self): simple_rgh = plan.compute_shoreline_roughness(simple_shore, simple_land) exp_area = 45 exp_len = (7 * 1) + (2 * 1.41421356) exp_rgh = exp_len / np.sqrt(exp_area) assert simple_rgh == pytest.approx(exp_rgh)
def test_compute_shoreline_roughness_asarray(self): # test it with default options _smarr = np.copy(self.sm.mask) _lmarr = np.copy(self.lm.mask) assert isinstance(_smarr, np.ndarray) assert isinstance(_lmarr, np.ndarray) rgh_3 = plan.compute_shoreline_roughness(_smarr, _lmarr) assert rgh_3 == pytest.approx(self.rcm8_expected, abs=0.1)
def test_rcm8_fail_no_land(self): # check raises error with pytest.raises(ValueError, match=r'No pixels in land mask.'): plan.compute_shoreline_roughness(self.sm, np.zeros((10, 10)))
def test_rcm8_defaults_opposite(self): # test that it is the same with opposite side origin rgh_2 = plan.compute_shoreline_roughness( self.sm, self.lm, origin=[0, self.rcm8.shape[1]]) assert rgh_2 == pytest.approx(self.rcm8_expected, abs=0.2)
def test_rcm8_ignore_return_line(self): # test that it ignores return_line arg rgh_1 = plan.compute_shoreline_roughness(self.sm, self.lm, return_line=False) assert rgh_1 == pytest.approx(self.rcm8_expected, abs=0.1)
def test_rcm8_defaults(self): # test it with default options rgh_0 = plan.compute_shoreline_roughness(self.sm, self.lm) assert rgh_0 == pytest.approx(self.rcm8_expected, abs=0.1)