Source code for iaa_od.visualisation.show_utils

from matplotlib.patches import Patch

[docs] def upsert_handle(handles: list[Patch], new_handle: Patch) -> None: """ Utility function that adds a new legend handle to the list of handles if it does not already exist. Parameters: handles (list[Patch]): The list of existing legend handles. new_handle (Patch): The new legend handle to add. """ for handle in handles: if handle.get_label() == new_handle.get_label(): return handles.append(new_handle)
[docs] def get_image_path(filename: str, filepath: str) -> str: """ Utility function that simply constructs the entire path for a given image filename. If necessary, the function also adds the ending forwards slash to the filepath. Parameters: filename (str): The image filename. filepath (str): The filepath where the image is located. Returns: str: The full path to the image. """ if filepath is None or filepath == "": raise ValueError("No filepath provided.") if filename is None or filename == "": raise ValueError("No filename provided.") if not filepath.endswith("/"): filepath += "/" return filepath + filename