Skip to content

QuadraticSpline edge-case crashes: n=2 BoundsError, Rational t starting at 0, duplicate knots #542

Description

@ChrisRackauckas-Claude

While verifying #531, three pre-existing edge-case failures in QuadraticSpline construction were confirmed on current master (they reproduce identically on the unmodified base, so they are independent of that PR):

  1. n = 2 throws BoundsError. QuadraticSpline(u, t) with two points fails in quadratic_spline_parameters' midpoint basis evaluation (src/parameter_caches.jl_spline_coefficients_body! writes N[0]). The knot/system construction itself handles n = 2 fine; it is the parameter midpoint evaluation that under-indexes.

    QuadraticSpline([1.0, 2.0], [0.0, 1.0])   # BoundsError
  2. Rational knots with t[1] == 0 throw DivideError. src/interpolation_utils.jl computes the coefficient eltype as dtype_sc = typeof(t[1] / t[1]), which evaluates 0//0 for Rational. A fix is typeof(one(eltype(t)) / one(eltype(t))).

    QuadraticSpline([1//1, 2//1, 3//1], [0//1, 1//1, 2//1])   # DivideError
  3. Duplicate knots throw SingularException. Both interior duplicates (t = [0, 1, 1, 2, 3]) and boundary duplicates (t[2] == t[1]) produce a singular tridiagonal collocation system. If duplicates are intentionally unsupported, an informative ArgumentError at construction would beat the raw SingularException from the linear solve.

All three were verified by running on a clean checkout of the merge-base (bf7c4edd) — error type and stacktrace location identical to the PR branch.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions