Display containers for LaTeX equation rendering.
Classes:
| Name | Description |
|---|---|
MathDisplay | Display wrapper for model equation with IPython rich display. |
TermInfo | Parsed information about a single model term. |
Classes¶
MathDisplay¶
Display wrapper for model equation with IPython rich display.
Renders as LaTeX in Jupyter notebooks and Quarto documents. Falls back to HTML+MathJax or plain text in other environments.
Created by: build_equation() Consumed by: model.show_math(), MathDisplay.to_markdown(), notebook display hooks Augmented by: Never
Attributes:
| Name | Type | Description |
|---|---|---|
equation | str | LaTeX equation string (without $$ delimiters). |
explanations | tuple[str, ...] | Term explanation strings. |
Examples:
>>> display = m.show_math()
>>> display.to_latex() # raw LaTeX string
>>> display # renders in JupyterFunctions:
| Name | Description |
|---|---|
to_latex | Get raw LaTeX equation string. |
to_markdown | Export equation as Quarto-compatible display math markdown. |
Attributes¶
equation¶
equation: str = field(validator=(validators.instance_of(str)))explanations¶
explanations: tuple[str, ...] = field(factory=tuple, validator=(validators.deep_iterable(member_validator=(validators.instance_of(str)))))Functions¶
to_latex¶
to_latex() -> strGet raw LaTeX equation string.
Returns:
| Type | Description |
|---|---|
str | LaTeX equation without $$ delimiters. |
to_markdown¶
to_markdown(path: str | Path | None = None, *, include_explanations: bool = True) -> strExport equation as Quarto-compatible display math markdown.
Wraps the equation in $$...$$ display math delimiters. When
include_explanations is True, appends the term explanations as
a bulleted list below the equation block.
Suitable for embedding in .qmd files via Quarto’s
{{< include >}} shortcode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | None | Optional file path to write the markdown. Parent directories are created automatically. If None, returns the string without writing. | None |
include_explanations | bool | If True (default), append term explanations below the equation. | True |
Returns:
| Type | Description |
|---|---|
str | Markdown string with $$equation$$ and optional |
str | explanations. |
Examples:
>>> m.show_math().to_markdown("equations/model_eq.md")
>>> md = m.show_math().to_markdown(include_explanations=False)TermInfo¶
Parsed information about a single model term.
Created by: categorize_term() Consumed by: build_lm_equation(), build_glm_equation(), build_mixed_equation() Augmented by: Never
Attributes:
| Name | Type | Description |
|---|---|---|
name | str | Original term name (e.g., “center(x1)”, “group[B]”). |
term_type | str | Category — “intercept”, “continuous”, “factor”, “interaction”, “transform”, or “poly”. |
base_var | str | Underlying variable name (e.g., “x1” for “center(x1)”). |
symbol | str | LaTeX symbol (e.g., r"\beta_1"). |
latex | str | Full LaTeX term (e.g., r"\beta_1 x_{1i}"). |
explanation | str | Human-readable explanation string. |
Attributes¶
base_var¶
base_var: str = field(validator=(validators.instance_of(str)))explanation¶
explanation: str = field(validator=(validators.instance_of(str)))latex¶
latex: str = field(validator=(validators.instance_of(str)))name¶
name: str = field(validator=(validators.instance_of(str)))symbol¶
symbol: str = field(validator=(validators.instance_of(str)))term_type¶
term_type: str = field(validator=(validators.instance_of(str)))