If the type of ``value`` is ``valid_type``, convert the value to list and expand to ``expand_dim``. Args: value (Any): value. valid_type (Union[Type, Tuple[Type, ...]): valid type. expand_dim (int): expand dim. Returns: List[Any]: value.
(value: Any, valid_type: Union[Type, Tuple[Type, ...]],
expand_dim: int)
| 25 | |
| 26 | |
| 27 | def value2list(value: Any, valid_type: Union[Type, Tuple[Type, ...]], |
| 28 | expand_dim: int) -> List[Any]: |
| 29 | """If the type of ``value`` is ``valid_type``, convert the value to list |
| 30 | and expand to ``expand_dim``. |
| 31 | |
| 32 | Args: |
| 33 | value (Any): value. |
| 34 | valid_type (Union[Type, Tuple[Type, ...]): valid type. |
| 35 | expand_dim (int): expand dim. |
| 36 | |
| 37 | Returns: |
| 38 | List[Any]: value. |
| 39 | """ |
| 40 | if isinstance(value, valid_type): |
| 41 | value = [value] * expand_dim |
| 42 | return value |
| 43 | |
| 44 | |
| 45 | def check_type(name: str, value: Any, |
no outgoing calls
no test coverage detected
searching dependent graphs…