fix: update chart risk label

This commit is contained in:
2026-07-06 18:44:55 +08:00
parent 9c3ad677b9
commit 9688ee208c
3 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -143,16 +143,18 @@ class PredictionHelpersTest(unittest.TestCase):
self.assertEqual(sample_worksheet["B1"].value, "00123")
self.assertEqual(sample_worksheet["B1"].data_type, "s")
def test_survival_chart_uses_pipe_age_x_axis_label(self) -> None:
def test_survival_chart_uses_expected_axis_labels(self) -> None:
df = pd.DataFrame({ID_COLUMN: ["P001"], PIPE_AGE_COLUMN: [12]})
with TemporaryDirectory() as temp_dir:
output_path = Path(temp_dir) / "chart.png"
with patch("app.prediction.plt.xlabel") as xlabel:
with patch("app.prediction.plt.xlabel") as xlabel, patch("app.prediction.plt.ylabel") as ylabel:
render_survival_chart(df, [DummyCurve([1, 2], [0.9, 0.7])], output_path)
xlabel.assert_called_once()
self.assertEqual(xlabel.call_args.args[0], "管龄(年)")
ylabel.assert_called_once()
self.assertEqual(ylabel.call_args.args[0], "健康风险")
if __name__ == "__main__":