Skip to content

Filter has no public constructor for hand picked coefficients #63

Description

@MitchellThompkins

Filter's only constructor that takes raw b and a arrays is protected. That means a user cannot build a Filter directly from coefficients they already have, whether from an external tool, hand tuning, or anywhere other than this library's own AnalogFilter, Butterworth, or Elliptic design path. Every constructor on Filter sits under one protected block, so a bare Filter cannot even be default constructed by a user.

Filter assumes a[0] equals 1 by convention but never checks it. Every current caller guarantees that mathematically through discretization, not through a runtime check, so protected access is implicitly standing in for that guarantee today. Making the raw constructor public needs to either add that check or document the assumption clearly, since a user could otherwise pass a non-monic a array and get silently wrong output with no signal (this relates slightly to #5 btw).

I Found this while reviewing the fixed point support added in #60. I had written in docs/fixed-point.md that a hand-constructed Filter was a valid input to FixedFilter, but that actually wasn't true for the non-fixed filter either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions