Skip to content

-1*param is serialized as -param #59

Closed

Description

@m-prl

When the symbolic expressions are serialized, -1*param is stored as -param in the impact models, which sometimes cannot be deserialized back into a symbolic expression.
This can lead to an invalid_expr when loading the model.

Traceback (most recent call last):
  File "C:\repositories\demo\run_impact_model.py", line 3, in <module>
    model = ImpactModel.from_yaml("data/impact_model.yaml")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\repositories\demo\.venv\Lib\site-packages\apparun\impact_model.py", line 176, in from_yaml
    return ImpactModel.from_dict(impact_model)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\repositories\demo\.venv\Lib\site-packages\apparun\impact_model.py", line 148, in from_dict
    tree=ImpactTreeNode.from_dict(impact_model["tree"]),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\repositories\demo\.venv\Lib\site-packages\apparun\impact_tree.py", line 138, in from_dict
    node = ImpactTreeNode(
           ^^^^^^^^^^^^^^^
  File "C:\repositories\demo\.venv\Lib\site-packages\pydantic\main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ImpactTreeNode
models
   [type=invalid_expr, input_value={'EFV3_CLIMATE_CHANGE': '... 21.707425626610416)))'}, input_type=dict]

A workaround is to manually replace each occurrence of -param by -1*param in the impact model.

Activity

  1. added theissue type on Apr 24, 2026
  2. changed the title [-]-1*param is serialized in -param[/-] [+]-1*param is serialized as -param[/+] on Apr 24, 2026
  3. self-assigned this
    on Apr 24, 2026
  4. linked a pull request that will close this issue(fix) correct validate_expr false positives #62on Jul 16, 2026
  5. m-prl commented on Jul 16, 2026

    @m-prl
    CollaboratorAuthor

    Fixed in release 0.4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions