mirror of
https://github.com/wassname/greater_tables_project.git
synced 2026-06-27 16:15:38 +08:00
pydantics tweaks, detex bug fix
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user