Skip to content

Make replacedimnames a no-op for an empty replacement set#216

Merged
mtfishman merged 1 commit into
mainfrom
mf/replaceinds-noop
Jul 10, 2026
Merged

Make replacedimnames a no-op for an empty replacement set#216
mtfishman merged 1 commit into
mainfrom
mf/replaceinds-noop

Conversation

@mtfishman

Copy link
Copy Markdown
Member

Summary

replacedimnames, and replaceinds which delegates to it, now return the tensor unchanged when given no replacement pairs instead of throwing. Base's replace(::AbstractArray) with no pairs errors with promote_valuetype(), unlike replace(::AbstractString) which returns the string, so the empty case has to be short-circuited explicitly. This lets callers pass a computed, possibly-empty set of relabelings without guarding the empty case themselves.

`replacedimnames`, and `replaceinds` which delegates to it, now return the tensor unchanged when given no replacement pairs instead of throwing. Base's `replace(::AbstractArray)` with no pairs errors with `promote_valuetype()`, unlike `replace(::AbstractString)` which returns the string, so the empty case has to be short-circuited explicitly. This lets callers pass a computed, possibly-empty set of relabelings without guarding the empty case themselves.
@mtfishman mtfishman enabled auto-merge (squash) July 10, 2026 19:49
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.00%. Comparing base (d1c09be) to head (8e896db).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #216      +/-   ##
==========================================
+ Coverage   75.99%   76.00%   +0.01%     
==========================================
  Files          30       30              
  Lines        1683     1684       +1     
==========================================
+ Hits         1279     1280       +1     
  Misses        404      404              
Flag Coverage Δ
docs 26.17% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtfishman mtfishman merged commit 4b6e859 into main Jul 10, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/replaceinds-noop branch July 10, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant