Skip to content

Bug: PlotPy stores custom colormaps in ~/.config/.none/ instead of its own configuration directory #70

Description

@StefanoPierini-Codra

Component: plotpy.config / plotpy.mathutils.colormap
Affected version: 2.11.0 and, as far as can be told, every earlier version
Severity: medium — user-created colormaps are written to a bogus directory, and never follow the host application's configuration directory

Symptom

  1. Custom colormaps created by the user are saved to ~/.config/.none/colormaps_custom.json (Windows: %USERPROFILE%\.none\colormaps_custom.json), not to a PlotPy-owned directory.
  2. A stray ~/.config/.none/ directory is created merely by importing PlotPy, even when the user never saves anything.
  3. When a host application claims a configuration directory via CONF.set_application("MyApp_v1/plotpy", …), the INI file moves but the colormaps do not: they keep pointing at .none.

Root cause

Two independent defects combine.

1. PlotPy never names its own UserConfig

plotpy/config.py:

CONF = UserConfig(DEFAULTS)

guidata.userconfig.UserConfig.__init__ sets self.name = "none", and get_path() resolves — and creates, via os.makedirs~/.config/.{self.name}/…. Without a set_application() call the name stays "none", so every path derived from CONF lands in ~/.config/.none/.

2. Colormap paths are resolved at import time and never refreshed

plotpy/mathutils/colormap.py computes its paths as module-level constants:

DEFAULT_COLORMAPS_PATH = get_cmap_path(CONF.get("colormaps", "colormaps/default", …))
CUSTOM_COLORMAPS_PATH = get_cmap_path(CONF.get("colormaps", "colormaps/custom", …))

CUSTOM_COLORMAPS_PATH is the file PlotPy writes to (save_colormaps(CUSTOM_COLORMAPS_PATH, CUSTOM_COLORMAPS)). A host application's set_application() call necessarily happens after plotpy.mathutils.colormap has been imported, so the path is already frozen. This is why symptom 3 affects host applications such as DataLab even though they do claim a configuration directory.

Note that PlotPy never calls CONF.save(), so no PlotPy settings are actually stored in .none/none.ini — that file belongs to guidata (see the companion issue). Only the colormaps are at stake.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions