コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)))
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
 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)