wrap_column

wrap_column(value, col_index=0, **kwargs)

Return (prefix, suffix) for column wrapping based on value type.

This is the main entry point for wrapping columns in keecas equations. Dispatches to specialized wrappers based on value type. For unhandled types, returns no wrapping (empty strings).

Parameters

value : Any Value to wrap (any type) col_index : int, optional Column index - 0 for LHS, 1+ for RHS (default: 0) LHS columns (0) typically get no wrapping RHS columns (1+) get type-specific decoration **kwargs Additional arguments (reserved for future use)

Returns

tuple[str, str] (prefix, suffix) tuple for wrapping the formatted value

Examples

from keecas import wrap_column, symbols

# Define symbol
x = symbols("x")

# LHS - no wrapping
wrap_column(x, col_index=0)  # Returns: ('', '')
('', '')
# RHS integer - equals prefix
wrap_column(42, col_index=1)  # Returns: ('= ', '')
('= ', '')
# RHS string - quad spacing
wrap_column("text", col_index=1)  # Returns: ('\quad', '')
('\\quad', '')

Notes

To register custom type wrappers:

# Define your custom type first
class MyType:
    pass

# Then register a wrapper for it
@wrap_column.register(MyType)
def wrap_mytype(value, col_index=0, **kwargs):
    if col_index == 0:
        return ("", "")
    return (r"\approx ", "")  # Custom prefix for RHS

Supported types (built-in registrations): - int: ‘=’ prefix for RHS - float: ‘=’ prefix for RHS - str: ‘’ prefix for RHS - sympy.Basic: ‘=’ prefix for RHS - pint.Quantity: ‘=’ prefix for RHS (optional) - IPython.display.Markdown: ‘’ prefix for RHS (optional) - IPython.display.Latex: ‘’ prefix for RHS (optional)

See Also

formatters.format_value : Cell formatter for type-based LaTeX conversion