diff --git a/history.txt b/history.txt index 202682e..bcc8a0a 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,5 @@ +* If the pipe diameter is not specified, the dent depth as a percentage of the diameter is 0. + 27.08.2026 ver.1.27 ------------------- diff --git a/pipeline_csv/csvfile/defect.py b/pipeline_csv/csvfile/defect.py index 6a06d5b..116c6da 100644 --- a/pipeline_csv/csvfile/defect.py +++ b/pipeline_csv/csvfile/defect.py @@ -85,6 +85,8 @@ def depth_percent(self): # Depth.HundredthsOfMillimeter if self.is_dent: + if self.pipe.diameter is None: + return 0 return float(self.row.depth_max) / float(self.pipe.diameter) return float(self.row.depth_max) / (self.pipe.thick / 10.0) diff --git a/tests/test/test_csv/test_defect.py b/tests/test/test_csv/test_defect.py index e5bcb9f..6a9feb4 100644 --- a/tests/test/test_csv/test_defect.py +++ b/tests/test/test_csv/test_defect.py @@ -89,6 +89,9 @@ def test_depth(self): # pylint: disable=too-many-statements assert mloss_defekt.depth_percent is None assert mloss_defekt.depth_mm is None + dent_defekt.pipe.diameter = None + assert dent_defekt.depth_percent == 0 + def test_props(self): # pylint: disable=too-many-statements """Check defekt properties.""" from pipeline_csv import TypeHorWeld