check

check(
    lhs,
    rhs,
    test=Le,
    template=None,
    success_template=None,
    failure_template=None,
    **kwargs,
)

Engineering verification function with localized pass/fail indicators.

Compares two expressions (already evaluated to numeric values) using a test function and displays a formatted message based on the pass/fail status. Return message can be templated as Latex object. The most common case is to be passed to a show_eqn function as secondary dict (the object will be formatted according to cell_formatter specification).

NOTE: if the test cannot evaluate to either True or False, an error will be raised. Common cause for this is that one of the arguments passed are not in the numeric form, but still in symbolic form.

Parameters

Name Type Description Default
lhs int | float evaluated left-hand side expression (e.g., calculated stress or utilization ratio). required
rhs int | float evaluated right-hand side expression (e.g., allowable limit or capacity). required
test type Comparison function from SymPy’s relational module. Options: - Le: LessThan (default, less than or equal) - Ge: GreaterThan (greater than or equal) - Lt: StrictLessThan (strictly less than) - Gt: StrictGreaterThan (strictly greater than) - Eq: Equality - Ne: Unequality Defaults to Le (less than or equal to). Le
template TemplateChoice | None Named template set for formatting. Options: “default”, “boxed”, “minimal”. Controls visual presentation of verification result. None
success_template str | None Custom template string for passing checks. Available variables: {symbol}, {rhs}, {verified_text}, {color}, {test_result}, {result_text}. None
failure_template str | None Custom template string for failing checks. Same variables as success_template. None
**kwargs Any Additional keyword arguments: - language (str): Document-level language override (e.g., ‘it’, ‘de’, ‘fr’) - substitutions (dict): Custom translation dictionary for “VERIFIED”/“NOT_VERIFIED” {}

Returns

Name Type Description
Latex IPython.display.Latex object that depends on conditions (true or false).

Examples

from keecas import symbols, u, pc, check
from sympy import Le, Ge

# Basic utilization check (calculated <= allowable)
sigma_Sd, sigma_Rd = symbols(r"\sigma_{Sd}, \sigma_{Rd}")
_p = {sigma_Sd: 150*u.MPa, sigma_Rd: 200*u.MPa}

utilization = sigma_Sd / sigma_Rd | pc.subs(_p) | pc.N
check(utilization, 1.0, test=Le)  # Check if <= 1.0 (passes)

\(\textcolor{green}{\left[\le1.0\quad \textbf{VERIFIED}\right]}\)

from keecas import show_eqn

# Capacity check (demand <= capacity)
N_Ed, N_Rd = symbols(r"N_{Ed}, N_{Rd}")
_p = {N_Ed: 850*u.kN, N_Rd: 1200*u.kN}

_e = {
    k: k | pc.subs(_p) | pc.N for k in [N_Ed/N_Rd]
}

_c = {
    k: check(v, 1.0) for k, v in _e.items()
}

# use along show_eqn
show_eqn([_p | _e, _c])

\[\begin{align} N_{Ed} & = 850{\,}\text{kN} & \\[8pt] N_{Rd} & = 1200{\,}\text{kN} & \\[8pt] \dfrac{N_{Ed}}{N_{Rd}} & = 0.708333333333333 & \quad\text{$\textcolor{green}{\left[\le1.0\quad \textbf{VERIFIED}\right]}$} \end{align}\]

# Multiple checks with different tests
tau_Sd, tau_Rd = symbols(r"\tau_{Sd}, \tau_{Rd}")
_v = {tau_Sd: 45*u.MPa, tau_Rd: 50*u.MPa}

# Check shear stress is less than limit
check(
    tau_Sd | pc.subs(_v) | pc.N,
    tau_Rd | pc.subs(_v) | pc.N,
    test=Le
)

\(\textcolor{green}{\left[\le50.0 \text{MPa}\quad \textbf{VERIFIED}\right]}\)

# Check capacity is greater than demand (reverse comparison)
check(
    tau_Rd | pc.subs(_v) | pc.N,
    tau_Sd | pc.subs(_v) | pc.N,
    test=Ge
)

\(\textcolor{green}{\left[\ge45.0 \text{MPa}\quad \textbf{VERIFIED}\right]}\)

# Localized verification (Italian)
from keecas import config
config.language.language = 'it'

utilization = 0.75
check(utilization, 1.0, test=Le)  # Shows "VERIFICATO" in Italian

\(\textcolor{green}{\left[\le1.0\quad \textbf{VERIFICATO}\right]}\)

# Custom templates for different visual styles
from IPython.display import display

# tip: use display() to show output for mid-cell statements
display(check(0.85, 1.0, template="boxed") )   # Boxed result
display(check(0.85, 1.0, template="minimal") ) # Minimal formatting
check(0.85, 1.0, template="default")  # Standard formatting
<IPython.core.display.Latex object>

\(\le1.0 \,\textcolor{green}{\checkmark}\)

\(\textcolor{green}{\left[\le1.0\quad \textbf{VERIFICATO}\right]}\)

See Also

Notes

  • Returns green indicator for passing checks, red for failing (default template)
  • Verification text (“VERIFIED”/“NOT_VERIFIED”) automatically localized per config.language
  • Supports 10 languages: de, es, fr, it, pt, da, nl, no, sv, en
  • Template variables allow full customization of output format
  • Commonly used with utilization ratios: check(calculated/allowable, 1.0)
  • Test functions from SymPy: Le, Ge, Lt, Gt, Eq, Ne