fix: update chart risk label
This commit is contained in:
+1
-1
@@ -456,7 +456,7 @@ def render_survival_chart(df: pd.DataFrame, curves, image_path: Path) -> tuple[l
|
|||||||
|
|
||||||
font_kwargs = chinese_font_kwargs()
|
font_kwargs = chinese_font_kwargs()
|
||||||
plt.xlabel("管龄(年)", **font_kwargs)
|
plt.xlabel("管龄(年)", **font_kwargs)
|
||||||
plt.ylabel("生存概率", **font_kwargs)
|
plt.ylabel("健康风险", **font_kwargs)
|
||||||
plt.title("预测分析图", **font_kwargs)
|
plt.title("预测分析图", **font_kwargs)
|
||||||
plt.grid(alpha=0.18)
|
plt.grid(alpha=0.18)
|
||||||
if len(summary_rows) <= 12:
|
if len(summary_rows) <= 12:
|
||||||
|
|||||||
Binary file not shown.
@@ -143,16 +143,18 @@ class PredictionHelpersTest(unittest.TestCase):
|
|||||||
self.assertEqual(sample_worksheet["B1"].value, "00123")
|
self.assertEqual(sample_worksheet["B1"].value, "00123")
|
||||||
self.assertEqual(sample_worksheet["B1"].data_type, "s")
|
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]})
|
df = pd.DataFrame({ID_COLUMN: ["P001"], PIPE_AGE_COLUMN: [12]})
|
||||||
|
|
||||||
with TemporaryDirectory() as temp_dir:
|
with TemporaryDirectory() as temp_dir:
|
||||||
output_path = Path(temp_dir) / "chart.png"
|
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)
|
render_survival_chart(df, [DummyCurve([1, 2], [0.9, 0.7])], output_path)
|
||||||
|
|
||||||
xlabel.assert_called_once()
|
xlabel.assert_called_once()
|
||||||
self.assertEqual(xlabel.call_args.args[0], "管龄(年)")
|
self.assertEqual(xlabel.call_args.args[0], "管龄(年)")
|
||||||
|
ylabel.assert_called_once()
|
||||||
|
self.assertEqual(ylabel.call_args.args[0], "健康风险")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user