Skip to content

Commit

Permalink
changes from pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolbhatia05 committed Jul 26, 2024
1 parent e41531f commit 7f25805
Show file tree
Hide file tree
Showing 9 changed files with 561 additions and 334 deletions.
5 changes: 3 additions & 2 deletions pyparamgui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
__email__ = "[email protected]"
__version__ = "0.0.1"

from .widget import widget, setup_widget_observer
from pyparamgui.widget import setup_widget_observer
from pyparamgui.widget import widget

__all__ = ['widget', 'setup_widget_observer']
__all__ = ["widget", "setup_widget_observer"]
8 changes: 4 additions & 4 deletions pyparamgui/generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""The glotaran generator module."""
"""The glotaran generator module."""

from __future__ import annotations

Expand Down Expand Up @@ -60,15 +60,15 @@ def _generate_decay_model(
"amplitude": f"shapes.species_{i+1}.amplitude",
"location": f"shapes.species_{i+1}.location",
"width": f"shapes.species_{i+1}.width",
"skewness": f"shapes.species_{i+1}.skewness"
"skewness": f"shapes.species_{i+1}.skewness",
}
for i in range(nr_compartments)
}
model["dataset"]["dataset_1"]["global_megacomplex"] = [ # type:ignore[index]
"megacomplex_spectral"
]
model["dataset"]["dataset_1"]["spectral_axis_inverted"] = True
model["dataset"]["dataset_1"]["spectral_axis_scale"] = 1E7
model["dataset"]["dataset_1"]["spectral_axis_scale"] = 1e7
if irf:
model["dataset"]["dataset_1"]["irf"] = "gaussian_irf" # type:ignore[index]
model["irf"] = {
Expand Down Expand Up @@ -193,7 +193,7 @@ class GeneratorArguments(TypedDict, total=False):
irf: bool


def generate_model(*, generator_name: str, generator_arguments: GeneratorArguments) -> Model:
def generate_model(*, generator_name: str, generator_arguments: GeneratorArguments) -> Model:
"""Generate a model.
Parameters
Expand Down
57 changes: 39 additions & 18 deletions pyparamgui/schema.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
"""This module has the different model classes representing different parameters, coordinates, and settings for simulation."""
"""This module has the different model classes representing different parameters, coordinates, and
settings for simulation."""

from __future__ import annotations

from typing import Dict

import numpy as np
from pydantic import BaseModel, ConfigDict
from pydantic import BaseModel
from pydantic import ConfigDict


class KineticParameters(BaseModel):
"""Kinetic parameters for the simulation.
Attributes:
decay_rates (list[float]): List of decay rates.
"""

decay_rates: list[float]


class SpectralParameters(BaseModel):
"""Spectral parameters for the simulation.
Expand All @@ -24,38 +29,43 @@ class SpectralParameters(BaseModel):
width (list[float]): List of widths.
skewness (list[float]): List of skewness values.
"""

amplitude: list[float]
location: list[float]
width: list[float]
skewness: list[float]


class TimeCoordinates(BaseModel):
"""
Time coordinates for the simulation.
"""Time coordinates for the simulation.
Attributes:
timepoints_max (int): Maximum number of time points.
timepoints_stepsize (float): Step size between time points.
"""

timepoints_max: int
timepoints_stepsize: float


class SpectralCoordinates(BaseModel):
"""
Spectral coordinates for the simulation.
"""Spectral coordinates for the simulation.
Attributes:
wavelength_min (int): Minimum wavelength.
wavelength_max (int): Maximum wavelength.
wavelength_stepsize (float): Step size between wavelengths.
"""

wavelength_min: int
wavelength_max: int
wavelength_stepsize: float

def generate_simulation_coordinates(time_coordinates: TimeCoordinates, spectral_coordinates: SpectralCoordinates) -> Dict[str, np.ndarray]:
"""
Generate simulation coordinates based on time and spectral coordinates.


def generate_simulation_coordinates(
time_coordinates: TimeCoordinates, spectral_coordinates: SpectralCoordinates
) -> Dict[str, np.ndarray]:
"""Generate simulation coordinates based on time and spectral coordinates.
Args:
time_coordinates (TimeCoordinates): The time coordinates for the simulation.
Expand All @@ -64,39 +74,49 @@ def generate_simulation_coordinates(time_coordinates: TimeCoordinates, spectral_
Returns:
Dict[str, np.ndarray]: A dictionary containing the time and spectral axes as numpy arrays.
"""
time_axis = np.arange(0, time_coordinates.timepoints_max * time_coordinates.timepoints_stepsize, time_coordinates.timepoints_stepsize)
spectral_axis = np.arange(spectral_coordinates.wavelength_min, spectral_coordinates.wavelength_max, spectral_coordinates.wavelength_stepsize)
time_axis = np.arange(
0,
time_coordinates.timepoints_max * time_coordinates.timepoints_stepsize,
time_coordinates.timepoints_stepsize,
)
spectral_axis = np.arange(
spectral_coordinates.wavelength_min,
spectral_coordinates.wavelength_max,
spectral_coordinates.wavelength_stepsize,
)
return {"time": time_axis, "spectral": spectral_axis}


class Settings(BaseModel):
"""
Other settings for the simulation.
"""Other settings for the simulation.
Attributes:
stdev_noise (float): Standard deviation of the noise to be added to the simulation data.
seed (int): Seed for the random number generator to ensure reproducibility.
add_gaussian_irf (bool): Flag to indicate whether to add a Gaussian Instrument Response Function (IRF) to the simulation. Default is False.
use_sequential_scheme (bool): Flag to indicate whether to use a sequential scheme in the simulation. Default is False.
"""

stdev_noise: float
seed: int
add_gaussian_irf: bool = False
use_sequential_scheme: bool = False


class IRF(BaseModel):
"""
Instrument Response Function (IRF) settings for the simulation.
"""Instrument Response Function (IRF) settings for the simulation.
Attributes:
center (float): The center position of the IRF.
width (float): The width of the IRF.
"""

center: float
width: float


class SimulationConfig(BaseModel):
"""
Configuration for the simulation, combining various parameters and settings.
"""Configuration for the simulation, combining various parameters and settings.
Attributes:
kinetic_parameters (KineticParameters): Kinetic parameters for the simulation.
Expand All @@ -105,6 +125,7 @@ class SimulationConfig(BaseModel):
settings (Settings): Other settings for the simulation, including noise standard deviation, random seed, and flags for adding Gaussian IRF and using a sequential scheme.
irf (IRF): Instrument Response Function (IRF) settings, including center position and width.
"""

kinetic_parameters: KineticParameters
spectral_parameters: SpectralParameters
coordinates: Dict[str, np.ndarray]
Expand Down
30 changes: 15 additions & 15 deletions pyparamgui/static/form.css
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
form {
display: flex;
flex-direction: column;
display: flex;
flex-direction: column;
}
.form-group {
display: flex;
align-items: center;
margin-bottom: 10px;
display: flex;
align-items: center;
margin-bottom: 10px;
}
label {
margin-right: 10px;
color: black;
width: 150px;
margin-right: 10px;
color: black;
width: 150px;
}
input {
flex: 1;
margin: 5px 0;
flex: 1;
margin: 5px 0;
}
hr {
margin: 20px 0;
border: none;
border-top: 1px solid #ccc;
margin: 20px 0;
border: none;
border-top: 1px solid #ccc;
}
button {
margin-top: 10px;
}
margin-top: 10px;
}
Loading

0 comments on commit 7f25805

Please sign in to comment.