From 19e8ad601050067c71d49e12ba203974aea2160b Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 21 Jul 2025 15:04:51 +0200 Subject: [PATCH] Remove vis info from petab.v2 Remove visualization tables until there is progress on https://github.com/PEtab-dev/libpetab-python/issues/398. --- petab/v2/C.py | 110 ------------------------------------------ petab/v2/lint.py | 20 -------- petab/v2/petab1to2.py | 10 ++-- petab/v2/problem.py | 24 +-------- 4 files changed, 5 insertions(+), 159 deletions(-) diff --git a/petab/v2/C.py b/petab/v2/C.py index 99abf343..9dee8959 100644 --- a/petab/v2/C.py +++ b/petab/v2/C.py @@ -233,114 +233,6 @@ #: Supported noise distributions NOISE_DISTRIBUTIONS = [NORMAL, LAPLACE, LOG_NORMAL, LOG_LAPLACE] - -# VISUALIZATION - -#: Plot ID column in the visualization table -PLOT_ID = "plotId" -#: Plot name column in the visualization table -PLOT_NAME = "plotName" -#: Value for plot type 'simulation' in the visualization table -PLOT_TYPE_SIMULATION = "plotTypeSimulation" -#: Value for plot type 'data' in the visualization table -PLOT_TYPE_DATA = "plotTypeData" -#: X values column in the visualization table -X_VALUES = "xValues" -#: X offset column in the visualization table -X_OFFSET = "xOffset" -#: X label column in the visualization table -X_LABEL = "xLabel" -#: X scale column in the visualization table -X_SCALE = "xScale" -#: Y values column in the visualization table -Y_VALUES = "yValues" -#: Y offset column in the visualization table -Y_OFFSET = "yOffset" -#: Y label column in the visualization table -Y_LABEL = "yLabel" -#: Y scale column in the visualization table -Y_SCALE = "yScale" -#: Legend entry column in the visualization table -LEGEND_ENTRY = "legendEntry" - -#: Mandatory columns of visualization table -VISUALIZATION_DF_REQUIRED_COLS = [PLOT_ID] - -#: Optional columns of visualization table -VISUALIZATION_DF_OPTIONAL_COLS = [ - PLOT_NAME, - PLOT_TYPE_SIMULATION, - PLOT_TYPE_DATA, - X_VALUES, - X_OFFSET, - X_LABEL, - X_SCALE, - Y_VALUES, - Y_OFFSET, - Y_LABEL, - Y_SCALE, - LEGEND_ENTRY, - DATASET_ID, -] - -#: Visualization table columns -VISUALIZATION_DF_COLS = [ - *VISUALIZATION_DF_REQUIRED_COLS, - *VISUALIZATION_DF_OPTIONAL_COLS, -] - -#: Visualization table columns that contain subplot specifications -VISUALIZATION_DF_SUBPLOT_LEVEL_COLS = [ - PLOT_ID, - PLOT_NAME, - PLOT_TYPE_SIMULATION, - PLOT_TYPE_DATA, - X_LABEL, - X_SCALE, - Y_LABEL, - Y_SCALE, -] - -#: Visualization table columns that contain single plot specifications -VISUALIZATION_DF_SINGLE_PLOT_LEVEL_COLS = [ - X_VALUES, - X_OFFSET, - Y_VALUES, - Y_OFFSET, - LEGEND_ENTRY, - DATASET_ID, -] - -#: Plot type value in the visualization table for line plot -LINE_PLOT = "LinePlot" -#: Plot type value in the visualization table for bar plot -BAR_PLOT = "BarPlot" -#: Plot type value in the visualization table for scatter plot -SCATTER_PLOT = "ScatterPlot" -#: Supported plot types -PLOT_TYPES_SIMULATION = [LINE_PLOT, BAR_PLOT, SCATTER_PLOT] - -#: Supported xScales -X_SCALES = [LIN, LOG, LOG10] - -#: Supported yScales -Y_SCALES = [LIN, LOG, LOG10] - - -#: Plot type "data" value in the visualization table for mean and standard -# deviation -MEAN_AND_SD = "MeanAndSD" -#: Plot type "data" value in the visualization table for mean and standard -# error -MEAN_AND_SEM = "MeanAndSEM" -#: Plot type "data" value in the visualization table for replicates -REPLICATE = "replicate" -#: Plot type "data" value in the visualization table for provided noise values -PROVIDED = "provided" -#: Supported settings for handling replicates -PLOT_TYPES_DATA = [MEAN_AND_SD, MEAN_AND_SEM, REPLICATE, PROVIDED] - - # YAML #: PEtab version key in the YAML file FORMAT_VERSION = "format_version" @@ -388,8 +280,6 @@ SIMULATION = "simulation" #: Residual value column in the residual table RESIDUAL = "residual" -#: ??? -NOISE_VALUE = "noiseValue" #: separator for multiple parameter values (bounds, observableParameters, ...) PARAMETER_SEPARATOR = ";" diff --git a/petab/v2/lint.py b/petab/v2/lint.py index 2810841a..a2fe9ae0 100644 --- a/petab/v2/lint.py +++ b/petab/v2/lint.py @@ -35,7 +35,6 @@ "CheckExperimentConditionsExist", "CheckAllParametersPresentInParameterTable", "CheckValidParameterInConditionOrParameterTable", - "CheckVisualizationTable", "CheckUnusedExperiments", "CheckObservablesDoNotShadowModelEntities", "CheckUnusedConditions", @@ -732,24 +731,6 @@ def run(self, problem: Problem) -> ValidationIssue | None: return None -class CheckVisualizationTable(ValidationTask): - """A task to validate the visualization table of a PEtab problem.""" - - def run(self, problem: Problem) -> ValidationIssue | None: - if problem.visualization_df is None: - return None - - from ..v1.visualize.lint import validate_visualization_df - - if validate_visualization_df(problem): - return ValidationIssue( - level=ValidationIssueSeverity.ERROR, - message="Visualization table is invalid.", - ) - - return None - - class CheckPriorDistribution(ValidationTask): """A task to validate the prior distribution of a PEtab problem.""" @@ -1064,7 +1045,6 @@ def get_placeholders( CheckUnusedExperiments(), CheckUnusedConditions(), # TODO: atomize checks, update to long condition table, re-enable - # CheckVisualizationTable(), # TODO validate mapping table CheckValidParameterInConditionOrParameterTable(), CheckAllParametersPresentInParameterTable(), diff --git a/petab/v2/petab1to2.py b/petab/v2/petab1to2.py index 2b6ec0e3..4e00481c 100644 --- a/petab/v2/petab1to2.py +++ b/petab/v2/petab1to2.py @@ -5,7 +5,6 @@ import re import shutil from contextlib import suppress -from itertools import chain from pathlib import Path from tempfile import TemporaryDirectory from urllib.parse import urlparse @@ -99,11 +98,9 @@ def petab_files_1to2(yaml_config: Path | str, output_dir: Path | str): file = yaml_config[v2.C.PARAMETER_FILE] v2.write_parameter_df(parameter_df, get_dest_path(file)) - # copy files that don't need conversion - # (models, visualizations) - for file in chain( - (model.location for model in new_yaml_config.model_files.values()), - new_yaml_config.visualization_files, + # copy files that don't need conversion: models + for file in ( + model.location for model in new_yaml_config.model_files.values() ): _copy_file(get_src_path(file), Path(get_dest_path(file))) @@ -289,7 +286,6 @@ def _update_yaml(yaml_config: dict) -> dict: v1.C.CONDITION_FILES, v1.C.MEASUREMENT_FILES, v1.C.OBSERVABLE_FILES, - v1.C.VISUALIZATION_FILES, ): if file_type in problem: yaml_config[file_type] = problem[file_type] diff --git a/petab/v2/problem.py b/petab/v2/problem.py index 97684241..06571e0a 100644 --- a/petab/v2/problem.py +++ b/petab/v2/problem.py @@ -26,7 +26,7 @@ validate_yaml_syntax, yaml, ) -from ..v1.core import concat_tables, get_visualization_df +from ..v1.core import concat_tables from ..v1.distributions import Distribution from ..v1.models.model import Model, model_factory from ..v1.yaml import get_path_prefix @@ -55,8 +55,6 @@ class Problem: - observable table - mapping table - Optionally, it may contain visualization tables. - See also :doc:`petab:v2/documentation_data_format`. """ @@ -69,7 +67,6 @@ def __init__( measurement_table: core.MeasurementTable = None, parameter_table: core.ParameterTable = None, mapping_table: core.MappingTable = None, - visualization_df: pd.DataFrame = None, config: ProblemConfig = None, ): from ..v2.lint import default_validation_tasks @@ -97,8 +94,6 @@ def __init__( parameters=[] ) - self.visualization_df = visualization_df - def __str__(self): model = f"with model ({self.model})" if self.model else "without model" @@ -257,15 +252,6 @@ def get_path(filename): else None ) - # TODO: remove in v2?! - visualization_files = [get_path(f) for f in config.visualization_files] - # If there are multiple tables, we will merge them - visualization_df = ( - concat_tables(visualization_files, get_visualization_df) - if visualization_files - else None - ) - observable_files = [get_path(f) for f in config.observable_files] # If there are multiple tables, we will merge them observable_df = ( @@ -289,7 +275,6 @@ def get_path(filename): parameter_df=parameter_df, observable_df=observable_df, model=model, - visualization_df=visualization_df, mapping_df=mapping_df, config=config, ) @@ -301,7 +286,6 @@ def from_dfs( experiment_df: pd.DataFrame = None, measurement_df: pd.DataFrame = None, parameter_df: pd.DataFrame = None, - visualization_df: pd.DataFrame = None, observable_df: pd.DataFrame = None, mapping_df: pd.DataFrame = None, config: ProblemConfig = None, @@ -315,7 +299,6 @@ def from_dfs( measurement_df: PEtab measurement table parameter_df: PEtab parameter table observable_df: PEtab observable table - visualization_df: PEtab visualization table mapping_df: PEtab mapping table model: The underlying model config: The PEtab problem configuration @@ -336,7 +319,6 @@ def from_dfs( measurement_table=measurement_table, parameter_table=parameter_table, mapping_table=mapping_table, - visualization_df=visualization_df, config=config, ) @@ -1117,8 +1099,7 @@ def model_dump(self, **kwargs) -> dict[str, Any]: 'measurement_files': [], 'model_files': {}, 'observable_files': [], - 'parameter_file': [], - 'visualization_files': []}, + 'parameter_file': []}, 'experiments': [], 'mappings': [], 'measurements': [], @@ -1191,7 +1172,6 @@ class ProblemConfig(BaseModel): condition_files: list[str | AnyUrl] = [] experiment_files: list[str | AnyUrl] = [] observable_files: list[str | AnyUrl] = [] - visualization_files: list[str | AnyUrl] = [] mapping_files: list[str | AnyUrl] = [] #: Extensions used by the problem.