def test_bad_masktype(self): with pytest.raises(TypeError): m, s = plan.compute_channel_depth(33, self.golf['depth'][-1, :, :], section=self.sec) with pytest.raises(TypeError): m, s = plan.compute_channel_depth(True, self.golf['depth'][-1, :, :], section=self.sec)
def test_depths_simple_list_equal(self): """Get mean, std, list from simple, check that same.""" m1, s1 = plan.compute_channel_depth(self.simple_cm, self.simple_depth, section=self.trace) m2, s2, w = plan.compute_channel_depth(self.simple_cm, self.simple_depth, section=self.trace, return_depths=True) assert m1 == (0.5 + 0.4 + 1 + 9) / 4 assert m1 == m2 assert s1 == s2 assert len(w) == 4
def test_depths_simple_thalweg(self): """Get mean and std from simple.""" m, s = plan.compute_channel_depth(self.simple_cm, self.simple_depth, section=self.trace) assert m == (0.5 + 0.4 + 1 + 9) / 4 assert s == pytest.approx(3.6299965564)
def test_depths_simple_mean(self): """Get mean and std from simple.""" m, s = plan.compute_channel_depth(self.simple_cm, self.simple_depth, section=self.trace, depth_type='mean') assert m == (0.5 + 0.3 + 1 + 9) / 4 assert s == pytest.approx(3.6462309307009066)
def test_depths_example_thalweg(self): """Get mean and std from example. This test does not actually test the computation, just that something valid is returned, i.e., the function takes the input. """ m, s = plan.compute_channel_depth(self.cm, self.golf['depth'][-1, :, :], section=self.sec) assert m > 0 assert s > 0
def test_no_section_make_default(self): with pytest.raises(NotImplementedError): m, s = plan.compute_channel_depth(self.cm, self.golf['depth'][-1, :, :])
def test_bad_depth_type_arg(self): with pytest.raises(ValueError): m, s = plan.compute_channel_depth(self.cm, self.golf['depth'][-1, :, :], depth_type='nonsense', section=self.sec)