Skip to main content

parse_shape_constraint

Function parse_shape_constraint 

Source
pub fn parse_shape_constraint(raw: &str) -> Result<ShapeConstraint, String>
Expand description

Parse a shape-constraint string into a ShapeConstraint.

This is the single source of truth shared by the formula DSL (s(x, shape=...)) and the smooths={...} override path (Smooth.shape_constraint). The accepted spellings cover the canonical Python ShapeConstraintLiteral strings exactly ("none" / "monotone_increasing" / "monotone_decreasing" / "convex" / "concave") plus a few common aliases. Hyphens and case are normalized, so "Monotone-Increasing" and "mono_inc" both resolve to ShapeConstraint::MonotoneIncreasing.