Skip to content

SCAN: Rename (user-facing) taps to lags and offer nicer constructor #1652

Description

@ricardoV94

Description

Writing multi-lagged inputs to Scan is not very intuitive. You pass a dictionary with outputs_info={"initial": var, "taps": [-2, -1]}. I don't usually remember the name of the keys, and also I don't think taps is a great name.

Syntatic-sugar suggestion, offer a function lags?

outputs_info=scan.lags(var, n=2) that creates the dict? Docstrings can be used to provide useful info for the user: What are lagged inputs, how a minimal step function may look like, what the input order is in the inner function (-2, -1), not (-1, -2), etc....

We can also call it scan.taps or something else. The main idea is having a function for discoverability / auto-completion

Next-level suggestion

If the user uses the lags constructor, the user function doesn't receive separate lagged arguments but a tuple of them?

def step(seq_val, lagged_var, constant):
  xtm2, xtm1 = lagged_var

GPT-5 explanation for the term taps:

Origin: “Taps” comes from signal processing. In FIR/IIR filters you read from a delay line at different “taps” (connection points) to access delayed samples; scan borrowed that for relative time-step reads.

GPT-5 name alternative suggestions:

Short answer
Better name: index_offsets (most general/clear), with time_offsets or lags as good alternates depending on audience.

Details

Why index_offsets: Scan iterates along an axis; the parameter is a set of relative indices w.r.t. the current step (e.g., [-2, -1, 0, +1]). “Index offsets” is precise, axis-agnostic, and conveys sign.

Other viable names (trade-offs):

  • time_offsets: very readable for time series; slightly misleading if the axis isn’t time.
  • lags: common in statistics; intuitive for negatives, less so for positives (often called “leads”).
  • delays: DSP-friendly; similar ambiguity for positive offsets.
  • relative_steps: explicit but longer.
  • lookback_steps: only fits negative offsets.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions