Skip to main content

Module term_builder

Module term_builder 

Source
Expand description

Term construction: bridge from parsed formula terms to TermCollectionSpec.

This module takes the AST produced by inference::formula_dsl and a loaded dataset, resolves column references, infers knot counts and center strategies, and produces a TermCollectionSpec ready for build_term_collection_design.

Enums§

DuchonPowerPolicy
TermBuilderError
Typed errors emitted by term-builder helpers. Display reproduces the exact pre-refactor format!(...) text byte-for-byte, so callers that string-match on the message (tests, log assertions) keep working unchanged. Public-API functions still return Result<_, String> and use .to_string() shims at their boundary to stay compatible with callers in protected modules.

Constants§

SECONDARY_CENTER_CAP_OPTION
Private (engine-injected) option that caps the default spatial center count for a secondary (distributional) predictor’s smooth — see solver::fit_orchestration::apply_secondary_predictor_basis_parsimony and #501.

Functions§

build_smooth_basis
build_termspec
col_minmax
column_map_with_alias
enable_scale_dimensions
Initialise per-axis anisotropic log-scales on eligible spatial smooth specs.
has_explicit_countwith_basis_alias
heuristic_centers
heuristic_knots_for_column
Per-column knot count from the unique-value count, with the same n^(1/3) ceiling growth as heuristic_knots so per-column smooths can support more detail at large scale. The 4-knot floor stays put because we still need enough basis functions to fit a non-trivial smooth at all.
parse_countwith_basis_alias
parse_cyclic_boundary
parse_duchon_order
parse_duchon_power
parse_duchon_power_policy
parse_periodic_domain_1d
Parse the periodic-uniform domain for a one-dimensional cyclic smooth.
resolve_col
Resolve a bare column name to its index, returning a typed DataError::ColumnNotFound on miss so the FFI boundary can surface a structured gamfit.ColumnNotFoundError(column=…, available=…) rather than rely on string-classification of human prose. Internal callers that still flow Result<_, String> get byte-identical text via From<DataError> for String.
resolve_role_col
Like resolve_col but tags the missing-column payload with a role label ("response", "entry", "exit", "event", "z", "id", …) so the boundary-side Python exception can disambiguate which formula slot held the bad reference.
resolve_smooth_type_name
smooth_type_uses_spatial_center_heuristic
Does this canonical smooth type size its basis through the generous spatial center heuristic (crate::basis::default_num_centers)?
spatial_center_strategy_for_dimension
unique_count_column
validate_known_options
Reject unknown option keys with a focused error that names the term and the offending key, plus suggests near-matches from the known-key list. Without this, typos like lengt_scale=0.1 or nyu=5/2 are silently dropped, the term uses the default, and the user has no idea why their option had no effect.