pydantics tweaks, detex bug fix

This commit is contained in:
Stephen Mildenhall
2025-06-22 09:43:11 +01:00
parent 64585bddb6
commit 6c3102e03a
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -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"
+4 -4
View File
@@ -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)