From 4ea2b91d643ea928d93645fcb9e13952e4b1b15d Mon Sep 17 00:00:00 2001 From: vedpatwardhan Date: Thu, 19 Sep 2024 22:57:29 +0000 Subject: [PATCH] updated docs --- mint.json | 1 + python/dataset.mdx | 2 +- python/repr.mdx | 197 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 python/repr.mdx diff --git a/mint.json b/mint.json index 4a6d05a..4d91197 100644 --- a/mint.json +++ b/mint.json @@ -112,6 +112,7 @@ "python/dataset", "python/evaluator", "python/logging", + "python/repr", "python/types", { "group": "utils", diff --git a/python/dataset.mdx b/python/dataset.mdx index 822fcc6..7a76e37 100644 --- a/python/dataset.mdx +++ b/python/dataset.mdx @@ -613,4 +613,4 @@ def __rich_repr__() -> List[Datum] Used by the rich package for representing and print the instance. - + diff --git a/python/repr.mdx b/python/repr.mdx new file mode 100644 index 0000000..ce54427 --- /dev/null +++ b/python/repr.mdx @@ -0,0 +1,197 @@ +--- +title: 'repr' +--- + + + +--- + +### repr\_mode + +```python +def repr_mode() -> str +``` + +Gets the global representation mode as currently set. This is used when representing +the various unify types on screen. Can be either "verbose" or "concise". + + + +--- + +### key\_repr + +```python +def key_repr(instance: _FormattedBaseModel) -> Union[Dict, List] +``` + +Get the key representation for the instance passed, either as the keys to keep or +the keys to remove. + +**Arguments**: + +- `instance` - The instance for which we want to retrieve the key repr policy. + + +**Returns**: + + Dict containing the policy, with a base key of "skip" or "keep", followed by + the nested structure of the elements to either remove or keep. + + + +--- + +### keys\_to\_skip + +```python +def keys_to_skip() -> Dict[Type, Dict] +``` + +Return the currently set keys to skip, which is a dict with types as keys and the +nested structure to skip as values. + + + +--- + +### set\_keys\_to\_skip + +```python +def set_keys_to_skip(skip_keys: Union[Dict[Type, Dict], str]) -> None +``` + +Set the keys to be skipped during representation, which is a dict with types as keys +and the nested structure to skip as values. + +**Arguments**: + +- `skip_keys` - The types as keywords arguments and dictionary representing the + structure of the keys to skip for that type as values. + + + +--- + +### keys\_to\_keep + +```python +def keys_to_keep() -> Dict[Type, Dict] +``` + +Return the currently set keys to keep, which is a dict with types as keys and the +nested structure to keep as values. + + + +--- + +### set\_keys\_to\_keep + +```python +def set_keys_to_keep(keep_keys: Union[Dict[Type, Dict], str]) -> None +``` + +Set the keys to be kept during representation, which is a dict with types as keys +and the nested structure to keep as values. + +**Arguments**: + +- `keep_keys` - The types as keywords arguments and dictionary representing the + structure of the keys to keep for that type as values. + + + +--- + +### set\_repr\_mode + +```python +def set_repr_mode(mode: str) -> None +``` + +Sets the global representation mode, to be used when representing the various unify +types on screen. Can be either "verbose" or "concise". + +**Arguments**: + +- `mode` - The value to set the mode to, either "verbose" or "concise". + + + +## ReprMode + +```python +class ReprMode(str) +``` + + + +--- + +### \_\_init\_\_ + +```python +def __init__(val: str) +``` + +Set a representation mode for a specific context in the code, by using the +`with` an instantiation of this class. + +**Arguments**: + +- `val` - The value of the string, must be either "verbose" or "concise". + + + +## KeepKeys + +```python +class KeepKeys() +``` + + + +--- + +### \_\_init\_\_ + +```python +def __init__(keep_keys: Union[Dict[Type, Dict], str]) +``` + +Set a the keys to keep for a specific context in the code, by using the +`with` an instantiation of this class. + +**Arguments**: + +- `keep_keys` - The types as keywords arguments and dictionary representing the + structure of the keys to keep for that type as values. + + + +## SkipKeys + +```python +class SkipKeys() +``` + + + +--- + +### \_\_init\_\_ + +```python +def __init__(skip_keys: Union[Dict[Type, Dict], str]) +``` + +Set a the keys to skip for a specific context in the code, by using the +`with` an instantiation of this class. + +**Arguments**: + +- `skip_keys` - The types as keywords arguments and dictionary representing the + structure of the keys to skip for that type as values. + +