INNER CODE UNIT · Python
_check_to_py_format
briscverse/ryp · ryp.py:1408
def _check_to_py_format(format: str | dict[str, str],
variable_name='format') -> None:
"""
Checks if format is a valid format argument for to_py().
Args:
format: the format argument
variable_name: the name of the format variable, used in error messages
"""
and_or = lambda valid: \
f'{", ".join(f"{key!r}" for key in valid[:-1])}, and/or {valid[-1]!r}'
valid_keys = 'vector', 'matrix', 'data.frame'
valid_values = 'polars', 'pandas', 'pandas-pyarrow', 'numpy'
if isinstance(format, dict):
if not format:
error_message = f'{variable_name} is an empty dictionary'
raise ValueError(error_message)
has_any_non_None_values = False