From 5d9ebee79b94a2e118d7cae35ea6bdb9c049ce01 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 29 Nov 2024 22:42:46 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- fluorescence_assay/plotting.py | 48 +++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/fluorescence_assay/plotting.py b/fluorescence_assay/plotting.py index 8c70ddf..8a15d09 100644 --- a/fluorescence_assay/plotting.py +++ b/fluorescence_assay/plotting.py @@ -1,27 +1,35 @@ """Module to plot parsed plate reader ouptputs.""" +from abc import ABC, abstractmethod +from dataclasses import dataclass, field +from typing import Optional + import matplotlib import matplotlib.pyplot as plt import numpy as np -from .plate_reader import Measurements, IControlXML - -from abc import ABC, abstractmethod -from dataclasses import dataclass, field -from typing import Optional +from .plate_reader import IControlXML, Measurements @dataclass class Plot(ABC): """""" - + @abstractmethod def load_data(self, Measurement: Measurements, *args, **kwargs) -> None: """""" ... - def format_plot(self, axes: matplotlib.axes._axes.Axes, xlim: Optional[list[float]] = None, ylim: Optional[list[float]] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None, square: Optional[bool] = False): - + def format_plot( + self, + axes: matplotlib.axes._axes.Axes, + xlim: Optional[list[float]] = None, + ylim: Optional[list[float]] = None, + xlabel: Optional[str] = None, + ylabel: Optional[str] = None, + square: Optional[bool] = False, + ): + if xlim is not None: axes.set_xlim(xlim) @@ -38,7 +46,6 @@ def format_plot(self, axes: matplotlib.axes._axes.Axes, xlim: Optional[list[floa axes.set_box_aspect(1) - @dataclass class IControlXMLPlot(Plot): """""" @@ -46,19 +53,34 @@ class IControlXMLPlot(Plot): _plate_read: dict = field(default_factory=dict, init=False) def load_data(self, IControlXML: IControlXML) -> None: - + self._plate_read = IControlXML def get_wavelength_axis(self, section) -> np.ndarray: - lmin, lmax, lstep = [self._plate_read.get_parameter(section, parameter) for parameter in ["Emission Wavelength Start", "Emission Wavelength End", "Emission Wavelength Step Size"]] + lmin, lmax, lstep = ( + self._plate_read.get_parameter(section, parameter) + for parameter in [ + "Emission Wavelength Start", + "Emission Wavelength End", + "Emission Wavelength Step Size", + ] + ) return np.arange(lmin, lmax + lstep, lstep) - def plot_well_spectrum(self, axes: matplotlib.axes._axes.Axes, section: str, well: str, cycle: Optional[int] = 1, color: Optional[tuple] = (0,0,0), label: Optional[str] = None) -> None: + def plot_well_spectrum( + self, + axes: matplotlib.axes._axes.Axes, + section: str, + well: str, + cycle: Optional[int] = 1, + color: Optional[tuple] = (0, 0, 0), + label: Optional[str] = None, + ) -> None: data = np.array(list(self._plate_read.get_well(section, well, cycle).values())) ll = self.get_wavelength_axis(section) - axes.plot(ll, data, color=color, label=label) \ No newline at end of file + axes.plot(ll, data, color=color, label=label)