Skip to content

Forcing

ForcingBase (DataBlockINIBasedModel) pydantic-model

validate(v) classmethod

Try to iniatialize subclass based on function field.

Source code in hydrolib/core/io/bc/models.py
@classmethod
def validate(cls, v):
    """Try to iniatialize subclass based on function field."""
    # should be replaced by discriminated unions once merged
    # https://github.com/samuelcolvin/pydantic/pull/2336
    if isinstance(v, dict):
        for c in cls.__subclasses__():
            if (
                c.__fields__.get("function").default
                == v.get("function", "").lower()
            ):
                v = c(**v)
                break
    return v

TimeInterpolation (str, Enum)

An enumeration.

VerticalInterpolation (str, Enum)

An enumeration.

VerticalPositionType (str, Enum)

An enumeration.

Back to top