mirror of https://github.com/gsi-upm/soil
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
739 B
Python
32 lines
739 B
Python
from __future__ import annotations
|
|
|
|
from typing_extensions import Annotated
|
|
import annotated_types
|
|
from typing import *
|
|
|
|
from dataclasses import dataclass
|
|
|
|
class Parameter:
|
|
pass
|
|
|
|
|
|
def floatrange(
|
|
*,
|
|
gt: Optional[float] = None,
|
|
ge: Optional[float] = None,
|
|
lt: Optional[float] = None,
|
|
le: Optional[float] = None,
|
|
multiple_of: Optional[float] = None,
|
|
) -> type[float]:
|
|
return Annotated[
|
|
float,
|
|
annotated_types.Interval(gt=gt, ge=ge, lt=lt, le=le),
|
|
annotated_types.MultipleOf(multiple_of) if multiple_of is not None else None,
|
|
]
|
|
|
|
function = Annotated[Callable, Parameter]
|
|
Integer = Annotated[int, Parameter]
|
|
Float = Annotated[float, Parameter]
|
|
|
|
|
|
probability = floatrange(ge=0, le=1) |