Skip to content

Move regularize anywhere more appropriate #285

Open

Description

@bvenn

The regularizeValues function is located in Interpolation.Approximation. While it is currently only used here, it is of bread interest to have this function available on a more global layer. It could be moved to the Seq/List/Array/Vector modules, or to its own source file in the Signal namespace.

Function

Zipping, sorting, aggregating at ties

let xData = [2;2;1;3]
let yData = [8;9;1;4]

regularizeValues xData yData Seq.mean
val it: seq<float * float> = seq [(1.0, 1.0); (2.0, 8.5); (3.0, 4.0)]

Activity

  1. github-actions commented on Apr 17, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    Agreed that regularizeValues has broad utility beyond interpolation. Here's a concrete migration path:

    Where it is now: Interpolation.Approximation.regularizeValues (line ~2173 of Interpolation.fs)

    Proposed move: Add the function to FSharp.Stats.Array, Seq, and List modules (or a shared helper module) with a more descriptive name — something like sortAndAggregateByKey or groupByKeyAndAggregate. The signature would generalise naturally:

    // In Array/Seq/List modules:
    val sortAndAggregateByKey : ('a -> 'b) -> (seq<'a> -> 'a) -> seq<('b * 'a)> -> seq<('b * 'a)>
    // or keeping the paired-arrays style:
    val regularize : x(redacted) -> y(redacted) -> ties:(seq<float> -> float) -> seq<float * float>

    Backward compatibility: Keep Interpolation.Approximation.regularizeValues as a thin wrapper calling the new location, marked [<Obsolete>] if desired.

    Benefit beyond interpolation: The function is also useful for histogramming, signal resampling, and any workflow where duplicate keys need aggregating before downstream processing — so Seq/Array feels like the right home.

    Happy to implement this as a PR if maintainers agree on the target location and naming.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions