Skip to content

[Repo Assist] Add Series.ZipInto, ZipAlignInto, ZipInner C# extension methods — addresses #524, #207#657

Merged
dsyme merged 2 commits intomasterfrom
repo-assist/improve-series-zip-csharp-extensions-6e73f6a5ccd49e00
Mar 19, 2026
Merged

[Repo Assist] Add Series.ZipInto, ZipAlignInto, ZipInner C# extension methods — addresses #524, #207#657
dsyme merged 2 commits intomasterfrom
repo-assist/improve-series-zip-csharp-extensions-6e73f6a5ccd49e00

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Repo Assist — adding C# extension methods for series combination operations.

Problem

Deedle's arithmetic operators on Series(K,V) only work for built-in numeric
types (int, float, decimal, etc.). C# users who want to combine two
series element-wise using a custom value type (e.g. a struct with its own
+ operator) have no ergonomic way to do so — the existing F# module
functions (Series.zipInto, Series.zipInner, Series.zipAlignInto) are
accessible from C# only through the static module syntax, not as fluent
instance methods.

This is the root cause of the issue reported in #524, and is part of the
broader C# API gap tracked in #207.

Solution

Three new [(Extension)] methods are added to SeriesExtensions.fs:

ZipInto — inner-join combination with a user function

// Primary workaround for #524 — combine custom-type series:
var sSum = s1.ZipInto(s2, (a, b) => a + b);               // inner join
var sProd = s1.ZipInto(s2, (a, b) => a * b);

ZipInner — inner-join, returns paired tuples

// Get aligned (V1, V2) tuples for further LINQ processing:
var pairs = s1.ZipInner(s2);   // Series(K, (V1, V2))
var combined = pairs.Select(kvp => kvp.Value.Item1 + kvp.Value.Item2);

ZipAlignInto — full-control variant with join kind and missing values

// Left join; produce missing when right value is absent:
var result = s1.ZipAlignInto(s2,
    (a, b) => b.HasValue
                  ? OptionalValue.Create(a.Value + b.Value)
                  : OptionalValue(MyType).Missing,
    JoinKind.Left,
    Lookup.Exact);
```

## Implementation

All three methods delegate to their existing F# counterparts
(`Series.zipInto`, `Series.zipInner`, `Series.zipAlignInto`).  No new
behaviour is introduced — this is purely a C# usability layer.

`ZipAlignInto` uses `OptionalValue(T)` (Deedle's own missing-value type)
rather than `FSharpOption(T)`, which is more natural from C#.

## Test Status

```
Passed!  - Failed: 0, Passed: 669, Skipped: 0, Total: 669

All 669 existing tests pass.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@30f2254f2a7a944da1224df45d181a3f8faefd0d

Three new instance-style extension methods for C# users:

- ZipInto(series2, Func<V1,V2,R>) — inner-join combination with a
  user-supplied function; the primary C# workaround for custom-type
  arithmetic (#524).
- ZipAlignInto(series2, Func<OptionalValue<V1>,OptionalValue<V2>,
  OptionalValue<R>>, JoinKind, Lookup) — full-control variant for
  outer / left / right join with missing-value handling via the
  Deedle-native OptionalValue<T> type.
- ZipInner(series2) — inner-join that returns Series<K, (V1,V2)>
  tuples; C# equivalent of the existing F# Series.zipInner.

These functions already existed in SeriesModule.fs; this PR exposes
them as ergonomic extension methods so C# users can call
s1.ZipInto(s2, (a, b) => a + b) in fluent chains.

Addresses #207 (C# API sync) and provides the recommended workaround
for #524 (generic operator overloading).

Co-authored-by: Copilot <[email protected]>
@dsyme dsyme marked this pull request as ready for review March 19, 2026 01:12
@dsyme dsyme merged commit d12653e into master Mar 19, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/improve-series-zip-csharp-extensions-6e73f6a5ccd49e00 branch March 19, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant