Global configuration for bossanova.
This module provides package-wide configuration settings that can be modified at runtime. Currently manages singular tolerance for mixed models.
Functions:
| Name | Description |
|---|---|
get_display_digits | Get the number of significant figures for DataFrame display output. |
get_singular_tolerance | Get the current singular tolerance for mixed models. |
is_singular | Check whether a mixed model fit is singular. |
set_display_digits | Set the number of significant figures for DataFrame display output. |
set_singular_tolerance | Set the global singular tolerance for mixed models. |
Functions¶
get_display_digits¶
get_display_digits() -> intGet the number of significant figures for DataFrame display output.
Controls how many significant figures are shown in user-facing
DataFrames returned by model properties (.params, .effects,
.diagnostics, etc.) and compare(). Matches R’s signif()
convention.
Returns:
| Type | Description |
|---|---|
int | Current display digits setting (default 4). |
Examples:
from bossanova import get_display_digits
get_display_digits()
# 4get_singular_tolerance¶
get_singular_tolerance() -> floatGet the current singular tolerance for mixed models.
The singular tolerance is used by isSingular() to determine if a mixed
model fit is singular (has variance components at or near zero).
Returns:
| Type | Description |
|---|---|
float | The current singular tolerance threshold. |
Examples:
from bossanova import get_singular_tolerance
get_singular_tolerance()
# 0.0001is_singular¶
is_singular(theta: np.ndarray | None, tol: float | None = None) -> boolCheck whether a mixed model fit is singular.
A fit is singular when any theta parameter (variance component on the relative scale) is at or near zero, indicating a variance component on the boundary of the parameter space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta | ndarray | None | Relative variance parameters from REML/ML optimization. None indicates no random effects (returns False). | required |
tol | float | None | Tolerance threshold. If None, uses the global singular tolerance from get_singular_tolerance(). | None |
Returns:
| Type | Description |
|---|---|
bool | True if any element of theta has absolute value below the tolerance. |
Examples:
from config import is_singular
import numpy as np
is_singular(np.array([0.5, 1e-6])) # True (1e-6 < 1e-4)
is_singular(np.array([0.5, 0.3])) # False
is_singular(None) # Falseset_display_digits¶
set_display_digits(digits: int) -> NoneSet the number of significant figures for DataFrame display output.
Controls how many significant figures are shown in user-facing
DataFrames returned by model properties (.params, .effects,
.diagnostics, etc.) and compare(). Matches R’s signif()
convention.
The summary() method has its own digits parameter and is
unaffected by this setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
digits | int | Number of significant figures. Must be >= 1. | required |
Examples:
from bossanova import set_display_digits
set_display_digits(6) # Show 6 significant figuresset_singular_tolerance¶
set_singular_tolerance(tol: float) -> NoneSet the global singular tolerance for mixed models.
The singular tolerance is used by isSingular() to determine if a mixed
model fit is singular. Values below this threshold are considered
effectively zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tol | float | New tolerance threshold. Must be positive. | required |
Examples:
from bossanova import set_singular_tolerance
set_singular_tolerance(1e-6) # More strict threshold