Coverage for kcpdi/utils.py: 83%
6 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-10-01 10:11 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-10-01 10:11 +0000
1import matplotlib.pyplot as plt
4def fig_ax(figsize=(15, 5), dpi=150):
5 """Generate a (matplotlib) figure and ax objects with given size."""
6 return plt.subplots(figsize=figsize, dpi=dpi)
9def get_sum_of_cost(algo, n_bkps) -> float:
10 """Calculate the sum of costs for the change points `bkps`.
12 Utility function used to do penalized variable selection and obtain
13 a final list of anomaly time points.
14 """
15 bkps = algo.predict(n_bkps=n_bkps)
16 return algo.cost.sum_of_costs(bkps)