Skip to content

Emit more precise warnings when executing control files. #93

@tyralla

Description

@tyralla

When failing to read a specific control or conditions file, HydPy adds the file's name to the error message:

NameError: While trying to initialise the model object of element `land_dill`, the following error occurred: While trying to load the control file "...\LahnH\control\default\land_dill.py", the following error occurred: name 'maxbas' is not defined

NameError: While trying to load the initial conditions of element `land_dill`, the following error occurred: name 'iz' is not defined

When emitting warnings, it does so only when reading condition files but not when reading control files:

UserWarning: For variable `lp` at least one value needed to be trimmed. The old and the new value(s) are `-0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5` and `0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0`, respectively.

UserWarning: For variable `sm` of element `land_dill` at least one value needed to be trimmed. The old and the new value(s) are `185.13164, 181.18755, 199.80432, 196.55888, 212.04018, 209.48859, 222.12115, 220.12671, 230.30756, 228.70779, 555.55555, 235.64427` and `185.13164, 181.18755, 199.80432, 196.55888, 212.04018, 209.48859, 222.12115, 220.12671, 230.30756, 228.70779, 278.0, 235.64427`, respectively.

The difference between both warnings is due to the typical workflow. HydPy queries the relevant Model instance from the control file and connects it to its Element instance afterwards before executing the conditions file. However, the warning mechanism can only add the element's name when the connection is already available.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions