Skip to content
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

plot_ppc modifies coords argument #2047

Closed
erocarrera opened this issue Jun 14, 2022 · 3 comments · Fixed by #2160
Closed

plot_ppc modifies coords argument #2047

erocarrera opened this issue Jun 14, 2022 · 3 comments · Fixed by #2160
Labels

Comments

@erocarrera
Copy link
Contributor

If this is the expected behavior it'd probably be good to mention it in the docstring. However I am inclined to think that the dictionary passed as coords should be left unmodified, it seems to be the behavior of a handful of plot_* functions that I've checked.

coords[key] = np.where(np.in1d(observed_data[key], coords[key]))[0]

@OriolAbril
Copy link
Member

They should not be modified, we should copy them before modifying, like we do with kwargs before we add default values

@tspeng
Copy link
Contributor

tspeng commented Nov 10, 2022

Hi @erocarrera and @OriolAbril, I am a new contributor. Based on your suggestions, I think it could be fixed by modifying the if statement in lines 270-271, so the original mutable object coords will not be modified. Since line 298 is an assignment operation, shallow copy should be enough.

if coords is None:
    coords = {}
else:
    coords = coords.copy()

@OriolAbril
Copy link
Member

Yes, that sounds good, thanks!

@OriolAbril OriolAbril linked a pull request Nov 15, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants