Skip to content

[BUG] Fix in-place mutation in make_strings_unique#553

Merged
fkiraly merged 5 commits into
sktime:mainfrom
SHIVANSH-ux-ys:fix-inplace-mutation
Jun 3, 2026
Merged

[BUG] Fix in-place mutation in make_strings_unique#553
fkiraly merged 5 commits into
sktime:mainfrom
SHIVANSH-ux-ys:fix-inplace-mutation

Conversation

@SHIVANSH-ux-ys

Copy link
Copy Markdown
Contributor

Fixes #551

The function make_strings_unique was mutating the input list in-place due to a direct reference assignment. This PR ensures a copy is created before modification.

Verified with a reproduction script:

mylist = ["a", "b", "a"]
make_strings_unique(mylist)
# mylist remains ["a", "b", "a"]

@fkiraly fkiraly added bug Something isn't working implementing framework Implementing core skbase framework labels May 17, 2026

@fkiraly fkiraly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

Can you add a test against regression? I.e., testing that the function no longer mutates its input?

@SHIVANSH-ux-ys

Copy link
Copy Markdown
Contributor Author

Hi @fkiraly,

I have added a regression test in skbase/utils/tests/test_iter.py to ensure that make_strings_unique does not mutate its input lists (verifying both flat and nested list inputs).

The test passes successfully. Ready for another review!

@SHIVANSH-ux-ys SHIVANSH-ux-ys requested a review from fkiraly May 20, 2026 04:26
@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.14%. Comparing base (306958d) to head (c777ab0).
⚠️ Report is 209 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #553      +/-   ##
==========================================
- Coverage   85.07%   84.14%   -0.93%     
==========================================
  Files          45       52       +7     
  Lines        3015     3961     +946     
==========================================
+ Hits         2565     3333     +768     
- Misses        450      628     +178     

☔ View full report in Codecov by Sentry.
📢 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.

@fkiraly fkiraly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fkiraly fkiraly merged commit e19ec4f into sktime:main Jun 3, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working implementing framework Implementing core skbase framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make_strings_unique mutates the caller's input list in-place instead of returning a modified copy

2 participants