Skip to content

shear_psf_leakage mutates global matplotlib rcParams at import — make plot style opt-in #78

Description

@cailmdaley

Reframed from "consolidate plot styles" — per-repo (and per-paper) plot styles are fine. The actual problem is an import-time side effect.

shear_psf_leakage/plot_style.py sets mpl.rcParams[...] at module top level, and leakage.py does from .plot_style import *. So importing shear_psf_leakage.leakage / run_scale / run_object silently mutates global matplotlib rcParams. sp_validation's cosmo_val imports exactly these:

  • cosmo_val/core.pyfrom shear_psf_leakage import run_object, run_scale
  • cosmo_val/psf_systematics.pyfrom shear_psf_leakage import leakage

…so sp_validation inherits shear_psf_leakage's plot style just by importing it — annoying in practice. (sp_validation/src/sp_validation/plots.py does the same import-time mutation within its own package.)

Fix (not style unification): move the rcParams-setting out of module top level into an explicit set_plot_style() that callers invoke when they want it. Importing a library should never change global matplotlib state; each repo/paper keeps whatever style it likes and applies it on purpose.

— Claude on behalf of Cail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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