-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
f471b67
commit 97d1cee
Showing
10 changed files
with
75 additions
and
31 deletions.
There are no files selected for viewing
Empty file.
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,33 @@ | ||
from dataclasses import field | ||
from typing import Any, Optional | ||
from pydantic import Field | ||
from autoflex.types import AutoflexFieldInfo, AutoflexParameterTypes | ||
|
||
|
||
def AutoflexField( | ||
default: Any = ..., | ||
*, | ||
autoflex_parameters: Optional[AutoflexParameterTypes] = None, | ||
**kwargs | ||
) -> AutoflexFieldInfo: | ||
""" | ||
A wrapper around pydantic's Field function that returns an instance of AutoflexFieldInfo | ||
instead of FieldInfo. | ||
Args: | ||
default: The default value of the field. | ||
autoflex_parameters: An additional argument specific to AutoflexFieldInfo. | ||
**kwargs: Any other keyword arguments passed to pydantic's Field. | ||
Returns: | ||
AutoflexFieldInfo: Custom field info object. | ||
""" | ||
|
||
field_info = Field(default=default, **kwargs) # Call pydantic's Field internally | ||
|
||
# Return an instance of AutoflexFieldInfo instead of the default FieldInfo | ||
return AutoflexFieldInfo( | ||
default=default, | ||
autoflex=autoflex_parameters, | ||
**field_info.dict(exclude_none=True) | ||
) |
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,3 @@ | ||
from autoflex.types.parameters import PhysicalParameter, AutoflexParameterTypes | ||
from autoflex.types.descriptors import Unit, Symbolic, SymbolicTypes | ||
from autoflex.types.field import AutoflexFieldInfo |
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,8 @@ | ||
import pydantic as pd | ||
from autoflex.types.parameters import AutoflexParameterTypes | ||
|
||
class AutoflexFieldInfo(pd.fields.FieldInfo): | ||
""" | ||
Each field should correspond to an individual parameter field that can represent it completely within the documentation. | ||
""" | ||
autoflex: AutoflexParameterTypes |
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,20 @@ | ||
from pydantic import Field | ||
from autoflex.types.core import AutoflexBaseModel | ||
from autoflex.types.descriptors import Unit, SymbolicTypes | ||
|
||
class PhysicalParameter(AutoflexBaseModel): | ||
""" | ||
This structure instance is a representation of the relevant information that might want to represent in a parameter | ||
row or in another container. | ||
We need the parameter name, the type definition in a format we might want to represent (or even interact with) | ||
a description which may be | ||
""" | ||
name: str = "" | ||
types: str = "" | ||
description: str = "" | ||
math: SymbolicTypes = Field(..., description="The mathematical representation defining the physical parameter in raw string latex") | ||
unit: Unit = Field(..., description="The unit of the physical parameter") | ||
|
||
|
||
AutoflexParameterTypes = PhysicalParameter |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
Descriptors | ||
------------ | ||
|
||
Part of the goal of using dedicated ``AutoflexField`` definitions is that we can compile this data into a nice way | ||
to visualise it both in the terminal and on the web. It can be used as a more helpful visualisation tool than the standard | ||
type descriptions. |
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