diff --git a/greater_tables/gtconfig.py b/greater_tables/gtconfig.py index da7cc09..7cd9459 100644 --- a/greater_tables/gtconfig.py +++ b/greater_tables/gtconfig.py @@ -9,7 +9,7 @@ Also includes functions for writing editable config templates and loading from Y from pathlib import Path -from typing import Optional, Union, Literal +from typing import Optional, Union, Literal, Callable, Any import yaml from pydantic import BaseModel, Field, ValidationError, ConfigDict @@ -56,8 +56,8 @@ class Configurator(BaseModel): None, description="Optional fallback formatter f-string" ) - table_float_format: Optional[str] = Field( - None, description="Float format string for the entire table; overrides column-specific formats" + table_float_format: Optional[Union[str, Callable[[Any, str], str]]] = Field( + None, description="Float format function or format string for the entire table; overrides column-specific formats" ) table_hrule_width: int = Field( 1, description="Width of top, bottom, and header horizontal rules" diff --git a/greater_tables/gtcore.py b/greater_tables/gtcore.py index 112a8bb..8315edf 100644 --- a/greater_tables/gtcore.py +++ b/greater_tables/gtcore.py @@ -2459,12 +2459,12 @@ class GT(object): def escape_index(idx): if isinstance(idx, pd.MultiIndex): return pd.MultiIndex.from_tuples( - [tuple(escape_tex_outside_math(x) for x in tup) for tup in idx], - names=[escape_tex_outside_math(n) if n else n for n in idx.names] + [tuple(GT.escape_tex_outside_math(x) for x in tup) for tup in idx], + names=[GT.escape_tex_outside_math(n) if n else n for n in idx.names] ) else: - return pd.Index([escape_tex_outside_math(x) for x in idx], - name=escape_tex_outside_math(idx.name) if idx.name else None) + return pd.Index([GT.escape_tex_outside_math(x) for x in idx], + name=GT.escape_tex_outside_math(idx.name) if idx.name else None) df.index = escape_index(df.index) df.columns = escape_index(df.columns)