Skip to content

[bug]: topoly breaks matplotlib plots when imported into a notebook #1360

@tobyallwood

Description

@tobyallwood

Checklist

  • Run using the main branch to check if the issue persists. Instructions on how to do this can be found here.
  • Find the offending file in the output. If processing halts, re-run analysis with topostats --core 1 process.
  • Describe the bug.
  • Include the configuration file.
  • Copy of the log-file from running with topostats --log-level debug <command>.
  • The exact command that failed. This is what you typed at the command line, including any options.
  • TopoStats version, this is reported by topostats --version
  • Operating System and Python Version

Describe the bug

If topoly is imported by a script imported by a notebook (first notebook -> topostats.processing -> topostats.tracing.ordered_tracing -> topoly) it changes matplotlib's backend mode from inline to something else (possibly Agg or similar).

In effect this causes plots to be displayed in new windows rather than in the notebook under cells which at a minimum is an inconvenience and for some machines will make the plots not viewable at all.

Copy of the log-file from running with topostats --log-level debug <command>

N/A

Include the configuration file

N/A

To Reproduce

  • Run a notebook that imports topoly.jones and topoly.translate_code, alternatively a notebook that imports topostats.processing as you can follow the imports from processing.py down to these topoly methods.
  • Create a basic plot and display it any way (plt.show(), fig)

TopoStats Version

Git main branch

Python Version

3.11

Operating System

Windows

Python Packages

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions