Skip to content

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

Open
SHIVANSH-ux-ys wants to merge 4 commits into
sktime:mainfrom
SHIVANSH-ux-ys:fix-inplace-mutation
Open

[BUG] Fix in-place mutation in make_strings_unique#553
SHIVANSH-ux-ys wants to merge 4 commits into
sktime:mainfrom
SHIVANSH-ux-ys:fix-inplace-mutation

Conversation

@SHIVANSH-ux-ys
Copy link
Copy Markdown

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
Copy link
Copy Markdown
Contributor

@fkiraly fkiraly left a comment

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
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!

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