-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
JB Lovland
committed
Jan 19, 2024
1 parent
8bfd41c
commit 1493b97
Showing
5 changed files
with
132 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Dict, Union | ||
|
||
from pydantic import RootModel | ||
|
||
|
||
class Parameters(RootModel[Dict[str, Union[int, float, str, "Parameters"]]]): | ||
... | ||
|
||
# root: dict[str, int | float | str | Parameters] | ||
|
||
|
||
# class Parameters(BaseModel): | ||
# parameters: Union[int, float, str, "Parameters"] | ||
|
||
# print(Parameters.model_rebuild()) | ||
# print(Parameters.model_json_schema()) | ||
print( | ||
Parameters.model_validate({"hello": "hello", "this": {"this": "that", "more": 1}}) | ||
) | ||
print( | ||
Parameters.model_validate( | ||
{ | ||
"SENSNAME": "faultseal", | ||
"SENSCASE": "low", | ||
"RMS_SEED": 1006, | ||
"INIT_FILES": { | ||
"PERM_FLUVCHAN_E1_NORM": 0.748433, | ||
"PERM_FLUVCHAN_E21_NORM": 0.782068, | ||
}, | ||
"KVKH_CHANNEL": 0.6, | ||
"KVKH_US": 0.6, | ||
"FAULT_SEAL_SCALING": 0.1, | ||
"FWL_CENTRAL": 1677, | ||
} | ||
) | ||
) |
Oops, something went wrong.