diff --git a/app/prediction.py b/app/prediction.py index e55edaf..65b4856 100644 --- a/app/prediction.py +++ b/app/prediction.py @@ -456,7 +456,7 @@ def render_survival_chart(df: pd.DataFrame, curves, image_path: Path) -> tuple[l font_kwargs = chinese_font_kwargs() plt.xlabel("管龄(年)", **font_kwargs) - plt.ylabel("生存概率", **font_kwargs) + plt.ylabel("健康风险", **font_kwargs) plt.title("预测分析图", **font_kwargs) plt.grid(alpha=0.18) if len(summary_rows) <= 12: diff --git a/example.xlsx b/example.xlsx index 60e345c..eb84766 100644 Binary files a/example.xlsx and b/example.xlsx differ diff --git a/tests/test_prediction.py b/tests/test_prediction.py index 242cef5..f5fd675 100644 --- a/tests/test_prediction.py +++ b/tests/test_prediction.py @@ -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__":