From d52aba465820bfdbcef21dd2fe2520f858c31cba Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Fri, 25 Sep 2026 11:57:02 +0200 Subject: [PATCH] Remove PEtab v2 mapping-table/YAML handling from petab.v1 petab.v1 had accumulated v2-only functionality (entity mapping table, extensions_config, and a deprecated v2-format YAML loading branch in Problem.from_yaml) that was implemented directly in the v1 package instead of v2, even though the v1 spec has no mapping table, no extensions, and no model_files/language keys. Move the mapping-table implementation to petab.v2.mapping (v2 no longer imports it from v1), strip mapping_df/extensions_config threading out of v1's Problem, lint, parameters, observables, and parameter_mapping modules, and make Problem.from_yaml raise a clear error for v2-format YAML instead of a deprecation warning followed by a broken load path. Non-SBML model support (PySB, BNGL) in petab.v1.models is left untouched. Co-Authored-By: Claude Sonnet 5 --- petab/v1/C.py | 28 ----------- petab/v1/__init__.py | 1 - petab/v1/lint.py | 63 +---------------------- petab/v1/observables.py | 12 ----- petab/v1/parameter_mapping.py | 18 +------ petab/v1/parameters.py | 16 ------ petab/v1/problem.py | 94 +++++++---------------------------- petab/v1/yaml.py | 5 -- petab/v2/__init__.py | 5 +- petab/{v1 => v2}/mapping.py | 5 +- 10 files changed, 23 insertions(+), 224 deletions(-) rename petab/{v1 => v2}/mapping.py (97%) diff --git a/petab/v1/C.py b/petab/v1/C.py index 09e94c20..533894de 100644 --- a/petab/v1/C.py +++ b/petab/v1/C.py @@ -335,15 +335,6 @@ PROBLEMS = "problems" #: SBML files key in the YAML file SBML_FILES = "sbml_files" -#: Model files key in the YAML file -# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C) -MODEL_FILES = "model_files" -#: Model location key in the YAML file -# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C) -MODEL_LOCATION = "location" -#: Model language key in the YAML file -# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C) -MODEL_LANGUAGE = "language" #: Condition files key in the YAML file CONDITION_FILES = "condition_files" #: Measurement files key in the YAML file @@ -352,25 +343,6 @@ OBSERVABLE_FILES = "observable_files" #: Visualization files key in the YAML file VISUALIZATION_FILES = "visualization_files" -#: Mapping files key in the YAML file -# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C) -MAPPING_FILES = "mapping_files" -#: Extensions key in the YAML file -# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C) -EXTENSIONS = "extensions" - - -# MAPPING - -#: PEtab entity ID column in the mapping table -# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C) -PETAB_ENTITY_ID = "petabEntityId" -#: Model entity ID column in the mapping table -# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C) -MODEL_ENTITY_ID = "modelEntityId" -#: Required columns of the mapping table -# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C) -MAPPING_DF_REQUIRED_COLS = [PETAB_ENTITY_ID, MODEL_ENTITY_ID] # MORE diff --git a/petab/v1/__init__.py b/petab/v1/__init__.py index 9402fe03..6fd1e2a4 100644 --- a/petab/v1/__init__.py +++ b/petab/v1/__init__.py @@ -12,7 +12,6 @@ from .core import * from .format_version import __format_version__ # noqa: F401 from .lint import * -from .mapping import * from .measurements import * from .models import Model # noqa: F401 from .observables import * diff --git a/petab/v1/lint.py b/petab/v1/lint.py index df9fc6e2..85375ea8 100644 --- a/petab/v1/lint.py +++ b/petab/v1/lint.py @@ -96,7 +96,6 @@ def check_condition_df( df: pd.DataFrame, model: Model | None = None, observable_df: pd.DataFrame | None = None, - mapping_df: pd.DataFrame | None = None, ) -> None: """Run sanity checks on PEtab condition table @@ -104,7 +103,6 @@ def check_condition_df( df: PEtab condition DataFrame model: Model for additional checking of parameter IDs observable_df: PEtab observables DataFrame - mapping_df: PEtab mapping DataFrame Raises: AssertionError: in case of problems @@ -141,11 +139,8 @@ def check_condition_df( petab.get_output_parameters( model=model, observable_df=observable_df, - mapping_df=mapping_df, ) ) - if mapping_df is not None: - allowed_cols |= set(mapping_df.index.values) for column_name in df.columns: if ( column_name != CONDITION_NAME @@ -217,7 +212,6 @@ def check_parameter_df( observable_df: pd.DataFrame | None = None, measurement_df: pd.DataFrame | None = None, condition_df: pd.DataFrame | None = None, - mapping_df: pd.DataFrame | None = None, ) -> None: """Run sanity checks on PEtab parameter table @@ -227,7 +221,6 @@ def check_parameter_df( observable_df: PEtab observable table for additional checks measurement_df: PEtab measurement table for additional checks condition_df: PEtab condition table for additional checks - mapping_df: PEtab mapping table for additional checks Raises: AssertionError: in case of problems @@ -286,7 +279,7 @@ def check_parameter_df( if model and measurement_df is not None and condition_df is not None: assert_all_parameters_present_in_parameter_df( - df, model, observable_df, measurement_df, condition_df, mapping_df + df, model, observable_df, measurement_df, condition_df ) @@ -355,7 +348,6 @@ def assert_all_parameters_present_in_parameter_df( observable_df: pd.DataFrame, measurement_df: pd.DataFrame, condition_df: pd.DataFrame, - mapping_df: pd.DataFrame = None, ) -> None: """Ensure all required parameters are contained in the parameter table with no additional ones @@ -366,7 +358,6 @@ def assert_all_parameters_present_in_parameter_df( observable_df: PEtab observable table measurement_df: PEtab measurement table condition_df: PEtab condition table - mapping_df: PEtab mapping table for additional checks Raises: AssertionError: in case of problems @@ -376,7 +367,6 @@ def assert_all_parameters_present_in_parameter_df( condition_df=condition_df, observable_df=observable_df, measurement_df=measurement_df, - mapping_df=mapping_df, ) allowed = parameters.get_valid_parameters_for_parameter_table( @@ -384,34 +374,12 @@ def assert_all_parameters_present_in_parameter_df( condition_df=condition_df, observable_df=observable_df, measurement_df=measurement_df, - mapping_df=mapping_df, ) actual = set(parameter_df.index) missing = required - actual extraneous = actual - allowed - # missing parameters might be present under a different name based on - # the mapping table - if missing and mapping_df is not None: - model_to_petab_mapping = {} - for map_from, map_to in zip( - mapping_df.index.values, mapping_df[MODEL_ENTITY_ID], strict=True - ): - if map_to in model_to_petab_mapping: - model_to_petab_mapping[map_to].append(map_from) - else: - model_to_petab_mapping[map_to] = [map_from] - missing = { - missing_id - for missing_id in missing - if missing_id not in model_to_petab_mapping - or all( - mapping_parameter not in actual - for mapping_parameter in model_to_petab_mapping[missing_id] - ) - } - if missing: raise AssertionError( "Missing parameter(s) in the model or the " @@ -893,13 +861,6 @@ def lint_problem(problem: "petab.Problem") -> bool: # pylint: disable=too-many-statements errors_occurred = False - if problem.extensions_config: - logger.warning( - "Validation of PEtab extensions is not yet implemented, " - "but the given problem uses the following extensions: " - f"{'', ''.join(problem.extensions_config.keys())}" - ) - # Run checks on individual files if problem.model is not None: logger.info("Checking model...") @@ -914,7 +875,6 @@ def lint_problem(problem: "petab.Problem") -> bool: problem.condition_df, model=problem.model, observable_df=problem.observable_df, - mapping_df=problem.mapping_df, ) except AssertionError as e: logger.error(e) @@ -963,7 +923,6 @@ def lint_problem(problem: "petab.Problem") -> bool: problem.observable_df, problem.measurement_df, problem.condition_df, - problem.mapping_df, ) except AssertionError as e: logger.error(e) @@ -981,7 +940,6 @@ def lint_problem(problem: "petab.Problem") -> bool: problem.model, problem.condition_df, problem.parameter_df, - problem.mapping_df, ) except AssertionError as e: logger.error(e) @@ -1017,7 +975,6 @@ def assert_model_parameters_in_condition_or_parameter_table( model: Model, condition_df: pd.DataFrame, parameter_df: pd.DataFrame, - mapping_df: pd.DataFrame = None, observable_df: pd.DataFrame = None, measurement_df: pd.DataFrame = None, ) -> None: @@ -1029,7 +986,6 @@ def assert_model_parameters_in_condition_or_parameter_table( parameter_df: PEtab parameter DataFrame model: PEtab model condition_df: PEtab condition table - mapping_df: PEtab mapping table observable_df: PEtab observable table measurement_df: PEtab measurement table @@ -1037,22 +993,6 @@ def assert_model_parameters_in_condition_or_parameter_table( AssertionError: in case of problems """ allowed_in_condition_cols = set(model.get_valid_ids_for_condition_table()) - if mapping_df is not None: - allowed_in_condition_cols |= { - from_id - for from_id, to_id in zip( - mapping_df.index.values, - mapping_df[MODEL_ENTITY_ID], - strict=True, - ) - if not pd.isna(to_id) - and ( - # mapping table entities mapping to already allowed parameters - to_id in allowed_in_condition_cols - # mapping table entities mapping to species - or model.is_state_variable(to_id) - ) - } allowed_in_parameter_table = ( parameters.get_valid_parameters_for_parameter_table( @@ -1060,7 +1000,6 @@ def assert_model_parameters_in_condition_or_parameter_table( condition_df=condition_df, observable_df=observable_df, measurement_df=measurement_df, - mapping_df=mapping_df, ) ) diff --git a/petab/v1/observables.py b/petab/v1/observables.py index d5862ccc..52fe99f4 100644 --- a/petab/v1/observables.py +++ b/petab/v1/observables.py @@ -80,7 +80,6 @@ def get_output_parameters( model: Model, observables: bool = True, noise: bool = True, - mapping_df: pd.DataFrame = None, ) -> list[str]: """Get output parameters @@ -92,7 +91,6 @@ def get_output_parameters( model: The underlying model observables: Include parameters from observableFormulas noise: Include parameters from noiseFormulas - mapping_df: PEtab mapping table Returns: List of output parameter IDs @@ -114,16 +112,6 @@ def get_output_parameters( if model.symbol_allowed_in_observable_formula(sym): continue - # does it map to a model entity? - if ( - mapping_df is not None - and sym in mapping_df.index - and model.symbol_allowed_in_observable_formula( - mapping_df.loc[sym, MODEL_ENTITY_ID] - ) - ): - continue - output_parameters[sym] = None return list(output_parameters.keys()) diff --git a/petab/v1/parameter_mapping.py b/petab/v1/parameter_mapping.py index 9bb09638..e9be5bed 100644 --- a/petab/v1/parameter_mapping.py +++ b/petab/v1/parameter_mapping.py @@ -22,7 +22,6 @@ parameters, ) from .C import * -from .mapping import resolve_mapping from .models import Model # FIXME import from petab.ENV_NUM_THREADS @@ -64,7 +63,6 @@ def get_optimization_to_simulation_parameter_mapping( measurement_df: pd.DataFrame, parameter_df: pd.DataFrame | None = None, observable_df: pd.DataFrame | None = None, - mapping_df: pd.DataFrame | None = None, sbml_model: libsbml.Model = None, simulation_conditions: pd.DataFrame | None = None, warn_unmapped: bool | None = True, @@ -152,7 +150,7 @@ def get_optimization_to_simulation_parameter_mapping( # Add output parameters that are not already defined in the model if observable_df is not None: output_parameters = observables.get_output_parameters( - observable_df=observable_df, model=model, mapping_df=mapping_df + observable_df=observable_df, model=model ) for par_id in output_parameters: simulation_parameters[par_id] = np.nan @@ -169,7 +167,6 @@ def get_optimization_to_simulation_parameter_mapping( measurement_df, condition_df, parameter_df, - mapping_df, model, simulation_parameters, warn_unmapped, @@ -191,7 +188,6 @@ def get_optimization_to_simulation_parameter_mapping( measurement_df, condition_df, parameter_df, - mapping_df, model, simulation_parameters, warn_unmapped, @@ -208,7 +204,6 @@ def _map_condition_arg_packer( measurement_df, condition_df, parameter_df, - mapping_df, model, simulation_parameters, warn_unmapped, @@ -223,7 +218,6 @@ def _map_condition_arg_packer( measurement_df, condition_df, parameter_df, - mapping_df, model, simulation_parameters, warn_unmapped, @@ -244,7 +238,6 @@ def _map_condition(packed_args): measurement_df, condition_df, parameter_df, - mapping_df, model, simulation_parameters, warn_unmapped, @@ -282,7 +275,6 @@ def _map_condition(packed_args): model=model, condition_df=condition_df, parameter_df=parameter_df, - mapping_df=mapping_df, simulation_parameters=simulation_parameters, warn_unmapped=warn_unmapped, scaled_parameters=scaled_parameters, @@ -297,7 +289,6 @@ def _map_condition(packed_args): model=model, condition_df=condition_df, parameter_df=parameter_df, - mapping_df=mapping_df, simulation_parameters=simulation_parameters, warn_unmapped=warn_unmapped, scaled_parameters=scaled_parameters, @@ -315,7 +306,6 @@ def get_parameter_mapping_for_condition( sbml_model: libsbml.Model = None, condition_df: pd.DataFrame = None, parameter_df: pd.DataFrame = None, - mapping_df: pd.DataFrame | None = None, simulation_parameters: dict[str, str] | None = None, warn_unmapped: bool = True, scaled_parameters: bool = False, @@ -339,8 +329,6 @@ def get_parameter_mapping_for_condition( PEtab condition DataFrame parameter_df: PEtab parameter DataFrame - mapping_df: - PEtab mapping DataFrame sbml_model: The SBML model (deprecated) model: @@ -421,7 +409,6 @@ def get_parameter_mapping_for_condition( condition_id, condition_df, model, - mapping_df, ) _apply_parameter_table( par_mapping, @@ -505,7 +492,6 @@ def _apply_condition_parameters( condition_id: str, condition_df: pd.DataFrame, model: Model, - mapping_df: pd.DataFrame | None = None, ) -> None: """Replace parameter IDs in parameter mapping dictionary by condition table parameter values (in-place). @@ -519,8 +505,6 @@ def _apply_condition_parameters( if overridee_id == CONDITION_NAME: continue - overridee_id = resolve_mapping(mapping_df, overridee_id) - # Species, compartments, and rule targets are handled elsewhere if model.is_state_variable(overridee_id): continue diff --git a/petab/v1/parameters.py b/petab/v1/parameters.py index 3efdaddb..1ea173e0 100644 --- a/petab/v1/parameters.py +++ b/petab/v1/parameters.py @@ -164,7 +164,6 @@ def create_parameter_df( parameter_scale: str = LOG10, lower_bound: Iterable | None = None, upper_bound: Iterable | None = None, - mapping_df: pd.DataFrame | None = None, ) -> pd.DataFrame: """Create a new PEtab parameter table @@ -185,7 +184,6 @@ def create_parameter_df( parameter_scale: parameter scaling lower_bound: lower bound for parameter value upper_bound: upper bound for parameter value - mapping_df: PEtab mapping DataFrame Returns: The created parameter DataFrame @@ -221,7 +219,6 @@ def create_parameter_df( condition_df=condition_df, observable_df=observable_df, measurement_df=measurement_df, - mapping_df=mapping_df, ) ) @@ -260,7 +257,6 @@ def get_required_parameters_for_parameter_table( condition_df: pd.DataFrame, observable_df: pd.DataFrame, measurement_df: pd.DataFrame, - mapping_df: pd.DataFrame = None, ) -> AbstractSet[str]: """ Get set of parameters which need to go into the parameter table @@ -270,7 +266,6 @@ def get_required_parameters_for_parameter_table( condition_df: PEtab condition table observable_df: PEtab observable table measurement_df: PEtab measurement table - mapping_df: PEtab mapping table Returns: Set of parameter IDs which PEtab requires to be present in the @@ -318,7 +313,6 @@ def append_overrides(overrides): output_parameters = observables.get_output_parameters( observable_df, model, - mapping_df=mapping_df, **formula_type, ) placeholders = observables.get_placeholders( @@ -349,7 +343,6 @@ def get_valid_parameters_for_parameter_table( condition_df: pd.DataFrame, observable_df: pd.DataFrame, measurement_df: pd.DataFrame, - mapping_df: pd.DataFrame = None, ) -> set[str]: """ Get set of parameters which may be present inside the parameter table @@ -359,14 +352,12 @@ def get_valid_parameters_for_parameter_table( condition_df: PEtab condition table observable_df: PEtab observable table measurement_df: PEtab measurement table - mapping_df: PEtab mapping table for additional checks Returns: Set of parameter IDs which PEtab allows to be present in the parameter table. """ # - grab all allowed model parameters - # - grab corresponding names from mapping table # - grab all output parameters defined in {observable,noise}Formula # - grab all parameters from measurement table # - grab all parametric overrides from condition table @@ -394,13 +385,6 @@ def get_valid_parameters_for_parameter_table( if p not in blackset ) - if mapping_df is not None: - for from_id, to_id in zip( - mapping_df.index.values, mapping_df[MODEL_ENTITY_ID], strict=True - ): - if to_id in parameter_ids: - parameter_ids[from_id] = None - if observable_df is not None: # add output parameters from observables table output_parameters = observables.get_output_parameters( diff --git a/petab/v1/problem.py b/petab/v1/problem.py index 96401f9b..fad64ce4 100644 --- a/petab/v1/problem.py +++ b/petab/v1/problem.py @@ -18,7 +18,6 @@ from . import ( conditions, core, - mapping, measurements, observables, parameter_mapping, @@ -51,7 +50,6 @@ class Problem: - measurement table - parameter table - observables table - - mapping table Optionally, it may contain visualization tables. @@ -63,12 +61,10 @@ class Problem: parameter_df: PEtab parameter table observable_df: PEtab observable table visualization_df: PEtab visualization table - mapping_df: PEtab mapping table model: The underlying model sbml_reader: Stored to keep object alive (deprecated). sbml_document: Stored to keep object alive (deprecated). sbml_model: PEtab SBML model (deprecated) - extensions_config: Information on the extensions used """ def __init__( @@ -83,8 +79,6 @@ def __init__( parameter_df: pd.DataFrame = None, visualization_df: pd.DataFrame = None, observable_df: pd.DataFrame = None, - mapping_df: pd.DataFrame = None, - extensions_config: dict | None = None, config: ProblemConfig = None, ): self.condition_df: pd.DataFrame | None = condition_df @@ -92,7 +86,6 @@ def __init__( self.parameter_df: pd.DataFrame | None = parameter_df self.visualization_df: pd.DataFrame | None = visualization_df self.observable_df: pd.DataFrame | None = observable_df - self.mapping_df: pd.DataFrame | None = mapping_df if any( (sbml_model, sbml_document, sbml_reader), @@ -119,7 +112,6 @@ def __init__( ) self.model: Model | None = model - self.extensions_config = extensions_config or {} self.config = config def __getattr__(self, name): @@ -186,7 +178,6 @@ def from_files( visualization_files: str | Path | Iterable[str | Path] | None = None, observable_files: str | Path | Iterable[str | Path] | None = None, model_id: str | None = None, - extensions_config: dict | None = None, ) -> Problem: """ Factory method to load model and tables from files. @@ -199,7 +190,6 @@ def from_files( visualization_files: PEtab visualization tables observable_files: PEtab observables tables model_id: PEtab ID of the model - extensions_config: Information on the extensions used """ warn( "petab.Problem.from_files is deprecated and will be removed in a " @@ -256,7 +246,6 @@ def from_files( parameter_df=parameter_df, observable_df=observable_df, visualization_df=visualization_df, - extensions_config=extensions_config, ) @staticmethod @@ -296,17 +285,11 @@ def get_path(filename): ) major_version = get_major_version(yaml_config) - if major_version not in {1, 2}: + if major_version != 1: raise ValueError( - "Provided PEtab files are of unsupported version " - f"{yaml_config[FORMAT_VERSION]}." - ) - if major_version == 2: - warn( - "Using petab.v1.Problem with PEtab2.0 is deprecated. " - "Use petab.v2.Problem instead.", - DeprecationWarning, - stacklevel=2, + "petab.v1.Problem.from_yaml() only supports PEtab 1.x " + f"files, but the given files are of version {major_version}. " + "Use petab.v2.Problem.from_yaml() instead." ) config = ProblemConfig( **yaml_config, base_path=base_path, filepath=filepath @@ -317,8 +300,6 @@ def get_path(filename): "must not be empty." ) problem0 = config.problems[0] - # currently required for handling PEtab v2 in here - problem0_ = yaml_config["problems"][0] if isinstance(config.parameter_file, list): parameter_df = parameters.get_parameter_df( @@ -330,39 +311,22 @@ def get_path(filename): if config.parameter_file else None ) - if major_version == 1: - if len(problem0.sbml_files) > 1: - # TODO https://github.com/PEtab-dev/libpetab-python/issues/6 - raise NotImplementedError( - "Support for multiple models is not yet implemented." - ) - model = ( - model_factory( - get_path(problem0.sbml_files[0]), - MODEL_TYPE_SBML, - model_id=None, - ) - if problem0.sbml_files - else None + if len(problem0.sbml_files) > 1: + # TODO https://github.com/PEtab-dev/libpetab-python/issues/6 + raise NotImplementedError( + "Support for multiple models is not yet implemented." ) - else: - if len(problem0_[MODEL_FILES]) > 1: - # TODO https://github.com/PEtab-dev/libpetab-python/issues/6 - raise NotImplementedError( - "Support for multiple models is not yet implemented." - ) - if not problem0_[MODEL_FILES]: - model = None - else: - model_id, model_info = next( - iter(problem0_[MODEL_FILES].items()) - ) - model = model_factory( - get_path(model_info[MODEL_LOCATION]), - model_info[MODEL_LANGUAGE], - model_id=model_id, - ) + + model = ( + model_factory( + get_path(problem0.sbml_files[0]), + MODEL_TYPE_SBML, + model_id=None, + ) + if problem0.sbml_files + else None + ) measurement_files = [get_path(f) for f in problem0.measurement_files] # If there are multiple tables, we will merge them @@ -400,14 +364,6 @@ def get_path(filename): else None ) - mapping_files = [get_path(f) for f in problem0_.get(MAPPING_FILES, [])] - # If there are multiple tables, we will merge them - mapping_df = ( - core.concat_tables(mapping_files, mapping.get_mapping_df) - if mapping_files - else None - ) - return Problem( condition_df=condition_df, measurement_df=measurement_df, @@ -415,8 +371,6 @@ def get_path(filename): observable_df=observable_df, model=model, visualization_df=visualization_df, - mapping_df=mapping_df, - extensions_config=yaml_config.get(EXTENSIONS, {}), config=config, ) @@ -487,7 +441,6 @@ def to_files_generic( "parameter", "observable", "visualization", - "mapping", ]: if getattr(self, f"{table_name}_df") is not None: filenames[f"{table_name}_file"] = f"{table_name}s.tsv" @@ -519,7 +472,6 @@ def to_files( prefix_path: None | str | Path = None, relative_paths: bool = True, model_file: None | str | Path = None, - mapping_file: None | str | Path = None, ) -> None: """ Write PEtab tables to files for this problem @@ -538,7 +490,6 @@ def to_files( parameter_file: Parameter table destination visualization_file: Visualization table destination observable_file: Observables table destination - mapping_file: Mapping table destination yaml_file: YAML file destination prefix_path: Specify a prefix to all paths, to avoid specifying the @@ -581,7 +532,6 @@ def add_prefix(path0: None | str | Path) -> str: parameter_file = add_prefix(parameter_file) observable_file = add_prefix(observable_file) visualization_file = add_prefix(visualization_file) - mapping_file = add_prefix(mapping_file) yaml_file = add_prefix(yaml_file) if model_file: @@ -630,12 +580,6 @@ def error(name: str) -> ValueError: else: raise error("visualization") - if mapping_file: - if self.mapping_df is not None: - mapping.write_mapping_df(self.mapping_df, mapping_file) - else: - raise error("mapping") - if yaml_file: yaml.create_problem_yaml( sbml_files=model_file, @@ -646,7 +590,6 @@ def error(name: str) -> ValueError: yaml_file=yaml_file, visualization_files=visualization_file, relative_paths=relative_paths, - mapping_files=mapping_file, ) def get_optimization_parameters(self) -> list[str]: @@ -922,7 +865,6 @@ def create_parameter_df(self, **kwargs): condition_df=self.condition_df, observable_df=self.observable_df, measurement_df=self.measurement_df, - mapping_df=self.mapping_df, **kwargs, ) diff --git a/petab/v1/yaml.py b/petab/v1/yaml.py index 0167934f..e8164708 100644 --- a/petab/v1/yaml.py +++ b/petab/v1/yaml.py @@ -256,7 +256,6 @@ def create_problem_yaml( yaml_file: str | Path, visualization_files: str | Path | list[str | Path] | None = None, relative_paths: bool = True, - mapping_files: str | Path | list[str | Path] | None = None, ) -> None: """Create and write default YAML file for a single PEtab problem @@ -273,7 +272,6 @@ def create_problem_yaml( whether all paths in the YAML file should be relative to the location of the YAML file. If ``False``, then paths are left unchanged. - mapping_files: Path of mapping file """ if isinstance(sbml_files, Path | str): sbml_files = [sbml_files] @@ -302,7 +300,6 @@ def get_rel_to_yaml(paths: list[str] | None): observable_files = get_rel_to_yaml(observable_files) visualization_files = get_rel_to_yaml(visualization_files) parameter_file = get_rel_to_yaml([parameter_file])[0] - mapping_files = get_rel_to_yaml(mapping_files) problem_dic = { CONDITION_FILES: condition_files, @@ -310,8 +307,6 @@ def get_rel_to_yaml(paths: list[str] | None): SBML_FILES: sbml_files, OBSERVABLE_FILES: observable_files, } - if mapping_files: - problem_dic[MAPPING_FILES] = mapping_files if visualization_files is not None: problem_dic[VISUALIZATION_FILES] = visualization_files diff --git a/petab/v2/__init__.py b/petab/v2/__init__.py index e67f2dea..d9d99318 100644 --- a/petab/v2/__init__.py +++ b/petab/v2/__init__.py @@ -5,10 +5,6 @@ # TODO: move this module to v2 from petab.v1.distributions import * -from petab.v1.mapping import ( # noqa: F401 - get_mapping_df, - write_mapping_df, -) from petab.v1.measurements import ( # noqa: F401 get_measurement_df, write_measurement_df, @@ -36,4 +32,5 @@ write_experiment_df, ) from .lint import lint_problem # noqa: F401 +from .mapping import get_mapping_df, write_mapping_df # noqa: F401 from .models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML, Model # noqa: F401 diff --git a/petab/v1/mapping.py b/petab/v2/mapping.py similarity index 97% rename from petab/v1/mapping.py rename to petab/v2/mapping.py index af344920..a2ad843d 100644 --- a/petab/v1/mapping.py +++ b/petab/v2/mapping.py @@ -1,13 +1,12 @@ """Functionality related to the PEtab entity mapping table""" -# TODO: Move to petab.v2.mapping from pathlib import Path import pandas as pd -from . import lint +from ..v1 import lint +from ..v1.models import Model from .C import * -from .models import Model __all__ = [ "check_mapping_df",