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

Disregard memory address for plots #753

Open
physkets opened this issue Apr 17, 2024 · 3 comments
Open

Disregard memory address for plots #753

physkets opened this issue Apr 17, 2024 · 3 comments

Comments

@physkets
Copy link

My git diffs are populated with a lot of entries every time I re-run cells that produce images, likely because the hashes include the memory address which changes each time.

Could this be avoided somehow?

This discussion began here:
https://groups.google.com/g/jupyter/c/srQPpo6otKc

@krassowski
Copy link
Member

The library which produces the plots likely uses a default text representation. Making it return something more stable should help. What library are you using and in which language?

@physkets
Copy link
Author

I am using python's matplotlib library.

How do I get it to do that?

@vidartf
Copy link
Collaborator

vidartf commented May 15, 2024

If the document has changed, it is the job of a VCS/diff tool to tell you about it. That said, you have a few options:

  1. Try to make matplotlib not generate this random text every time.
  2. Use a tool to avoid saving outputs to git (multiple options exist), but of course then you will not be able to see the previous outputs. Some specific tools for notebook exists (jupytext, nbstripout), but you could also try to make your own to target this specific issue.
  3. Configure your diff tool to ignore the outputs. E.g. for nbdime you can do this via command line flags, but note that this will ignore ALL outputs, not just the ones mentioned. And even if your diff tool doesn't show it, git will still keep committing it, and it will show up other places.

Given all this, option 1 definitely seems like the cleanest solution if you are able to, but that isn't really something we can help you with though.

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

No branches or pull requests

3 participants