# Path: metatlas/io/metatlas_get_data_helper_fun.py
# def get_bpc(filename,dataset='ms1_pos',integration='bpc'):
#     """
#     Gets the basepeak chromatogram for a file.
#     filename: File can be either a metatlas lcmsrun object or a full path to an hdf5file
#     dataset: ms1_pos, ms1_neg, ms2_pos, ms2_neg
# 
#     Returns:
#     A pandas dataframe with the value at the maximum intensity at each retention time
#     """
#     df_container = df_container_from_metatlas_file(filename)
#     if integration=='bpc':
#         bpc = df_container[dataset].sort_values('i', ascending=False).groupby('rt', as_index=False).first().sort_values('rt',ascending=True)
#         return bpc
#     else:
#         tic = df_container[dataset][['rt','i']].groupby('rt',as_index=False).sum().sort_values('rt',ascending=True)
#         return tic
# 
# Path: metatlas/plots/plot_set.py
# def restore_matplotlib_settings(func):
#     def wrapper(*args, **kwargs):
#     def __init__(self, title: str, group_name: str):
#     def plot(self, ax: matplotlib.axes.Axes, back_color: utils.Color = "white") -> None:
#     def __init__(
#         self,
#         plots: Sequence[Plot],
#         max_plots_per_fig: int = 30,
#         x_min: Optional[float] = None,
#         x_max: Optional[float] = None,
#         y_min: Optional[float] = None,
#         y_max: Optional[float] = None,
#         sharey: bool = True,
#         font_scale: float = 2,
#     ):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, exc_tb):
#     def limit_axes(
#         self,
#         x_min: Optional[float],
#         x_max: Optional[float],
#         y_min: Optional[float],
#         y_max: Optional[float],
#     ) -> None:
#     def save_pdf(self, file_name: str, title: str, overwrite: bool = False) -> None:
#     def close(self):
# def _get_xy(artist: matplotlib.artist.Artist) -> Tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]:
# def _autoscale(ax: matplotlib.axes.Axes, axis: str = "y", sides: str = "both", margin: float = 0.1) -> None:
# def _update_limts(
#     low: float,
#     high: float,
#     fixed: npt.NDArray[np.float64],
#     dependent: npt.NDArray[np.float64],
#     fixed_limits: Tuple[float, float],
# ) -> Tuple[float, float]:
# def _calculate_new_limit(
#     fixed: npt.NDArray[np.float64], dependent: npt.NDArray[np.float64], fixed_limits: Tuple[float, float]
# ) -> Tuple[float, float]:
# class Plot(ABC):
# class PlotSet(ABC):
# 
# Path: metatlas/plots/utils.py
# BACKGROUND_COLORS = ["white", "lightyellow", "whitesmoke", "lavenderblush"]
# def colors() -> Generator:
# def subplot_dimensions(num: int) -> Tuple[int, int]:
# def wrap_subplots(num: int, **kwargs) -> Tuple[matplotlib.figure.Figure, List[matplotlib.axes.Axes]]:
# def is_in_range(a: List[float], start: float, stop: float) -> List[bool]:
# def fill_under(
#     ax: matplotlib.axes.Axes,
#     x: List[float],
#     y: List[float],
#     between: Optional[Tuple[float, float]] = None,
#     **kwargs,
# ) -> None:
# def pdf_with_text(text: str, file_name: str, size: int = 24):


import logging
import matplotlib
from pathlib import Path
from typing import Any, List, Optional
from matplotlib.ticker import MultipleLocator
from metatlas.io.metatlas_get_data_helper_fun import get_bpc
from metatlas.plots import plot_set
from metatlas.plots import utils
"""Plot set of TIC plots. One sample per sub-plot"""
# pylint: disable=invalid-name,too-many-arguments,too-few-public-methods,too-many-locals





logger = logging.getLogger(__name__)

MetatlasDataset = List[List[Any]]  # avoiding a circular import


class Tic(plot_set.Plot):
    """TIC for a single sample"""

    def __init__(self, title: str, group_name: str, h5_file_name: str, polarity: str):
        super().__init__(title, group_name)
        self.h5_file_name = h5_file_name
        assert polarity in ["positive", "negative"]
        self.polarity = polarity


# Path: metatlas/io/metatlas_get_data_helper_fun.py
# def get_bpc(filename,dataset='ms1_pos',integration='bpc'):
#     """
#     Gets the basepeak chromatogram for a file.
#     filename: File can be either a metatlas lcmsrun object or a full path to an hdf5file
#     dataset: ms1_pos, ms1_neg, ms2_pos, ms2_neg
# 
#     Returns:
#     A pandas dataframe with the value at the maximum intensity at each retention time
#     """
#     df_container = df_container_from_metatlas_file(filename)
#     if integration=='bpc':
#         bpc = df_container[dataset].sort_values('i', ascending=False).groupby('rt', as_index=False).first().sort_values('rt',ascending=True)
#         return bpc
#     else:
#         tic = df_container[dataset][['rt','i']].groupby('rt',as_index=False).sum().sort_values('rt',ascending=True)
#         return tic
# 
# Path: metatlas/plots/plot_set.py
# def restore_matplotlib_settings(func):
#     def wrapper(*args, **kwargs):
#     def __init__(self, title: str, group_name: str):
#     def plot(self, ax: matplotlib.axes.Axes, back_color: utils.Color = "white") -> None:
#     def __init__(
#         self,
#         plots: Sequence[Plot],
#         max_plots_per_fig: int = 30,
#         x_min: Optional[float] = None,
#         x_max: Optional[float] = None,
#         y_min: Optional[float] = None,
#         y_max: Optional[float] = None,
#         sharey: bool = True,
#         font_scale: float = 2,
#     ):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, exc_tb):
#     def limit_axes(
#         self,
#         x_min: Optional[float],
#         x_max: Optional[float],
#         y_min: Optional[float],
#         y_max: Optional[float],
#     ) -> None:
#     def save_pdf(self, file_name: str, title: str, overwrite: bool = False) -> None:
#     def close(self):
# def _get_xy(artist: matplotlib.artist.Artist) -> Tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]:
# def _autoscale(ax: matplotlib.axes.Axes, axis: str = "y", sides: str = "both", margin: float = 0.1) -> None:
# def _update_limts(
#     low: float,
#     high: float,
#     fixed: npt.NDArray[np.float64],
#     dependent: npt.NDArray[np.float64],
#     fixed_limits: Tuple[float, float],
# ) -> Tuple[float, float]:
# def _calculate_new_limit(
#     fixed: npt.NDArray[np.float64], dependent: npt.NDArray[np.float64], fixed_limits: Tuple[float, float]
# ) -> Tuple[float, float]:
# class Plot(ABC):
# class PlotSet(ABC):
# 
# Path: metatlas/plots/utils.py
# BACKGROUND_COLORS = ["white", "lightyellow", "whitesmoke", "lavenderblush"]
# def colors() -> Generator:
# def subplot_dimensions(num: int) -> Tuple[int, int]:
# def wrap_subplots(num: int, **kwargs) -> Tuple[matplotlib.figure.Figure, List[matplotlib.axes.Axes]]:
# def is_in_range(a: List[float], start: float, stop: float) -> List[bool]:
# def fill_under(
#     ax: matplotlib.axes.Axes,
#     x: List[float],
#     y: List[float],
#     between: Optional[Tuple[float, float]] = None,
#     **kwargs,
# ) -> None:
# def pdf_with_text(text: str, file_name: str, size: int = 24):


# Path: metatlas/plots/tic.py
import logging
import matplotlib
from pathlib import Path
from typing import Any, List, Optional
from matplotlib.ticker import MultipleLocator
from metatlas.io.metatlas_get_data_helper_fun import get_bpc
from metatlas.plots import plot_set
from metatlas.plots import utils

"""Plot set of TIC plots. One sample per sub-plot"""
# pylint: disable=invalid-name,too-many-arguments,too-few-public-methods,too-many-locals





logger = logging.getLogger(__name__)

MetatlasDataset = List[List[Any]]  # avoiding a circular import


class Tic(plot_set.Plot):
    """TIC for a single sample"""

    def __init__(self, title: str, group_name: str, h5_file_name: str, polarity: str):
        super().__init__(title, group_name)
        self.h5_file_name = h5_file_name
        assert polarity in ["positive", "negative"]
        self.polarity = polarity


    def plot(self, ax: matplotlib.axes.Axes, back_color: utils.Color = "white") -> None: