Skip to content

[MRG] FIX: Ensure dictionary is writeable #11342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2018

Conversation

jakirkham
Copy link
Contributor

As the dictionary in dict_learning_online can be supplied by the user and we intend to write to it, ensure that it is writable before proceeding. This is needed as dict_learning_online will overwrite data in dictionary as it runs. Tweak an existing test to initialize dict_learning_online with a read-only dictionary and ensure it will reach code that tries to write to the read-only dictionary (unless we ensure it is writeable).

As the `dictionary` in `dict_learning_online` can be supplied by the
user and we intend to write to it, ensure that it is writable before
proceeding. This is needed as `dict_learning_online` will overwrite data
in `dictionary` as it runs.
@jakirkham jakirkham force-pushed the ensure_dict_writeable branch from 4bdf305 to f4547a8 Compare June 21, 2018 22:37
Add a new test based on an existing one with a user provided dictionary
to ensure that if the array is read-only, `dict_learning_online` will
turn it into a writable array (copying if needed). Without the fix
included this test will fail by trying to write to the dictionary, which
is read-only due to the initialization condition.
@jakirkham jakirkham force-pushed the ensure_dict_writeable branch from f4547a8 to 0104261 Compare June 22, 2018 00:06
@jakirkham jakirkham changed the title FIX: Ensure dictionary is writeable [MRG] FIX: Ensure dictionary is writeable Jun 22, 2018
@agramfort
Copy link
Member

LGTM but I wonder if we should have a more general approach to this?

I would say not necessarily as it's here a function that is updated and not an estimator.

@jakirkham
Copy link
Contributor Author

It might be worth adding copying parameters if that is what you mean. Though in some cases copying happens anyways. So they would act more like suggestions than requirements.

Given this case just failed, opted to just fix the bug without altering existing behavior.

@jnothman jnothman merged commit 62301aa into scikit-learn:master Jun 23, 2018
@jnothman
Copy link
Member

Thanks @jakirkham

@jakirkham jakirkham deleted the ensure_dict_writeable branch June 25, 2018 00:03
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.

3 participants