Repository navigation
Fix custom colormaps location (store them in the application config dir) - #88
Merged
Merged
Conversation
PlotPy's configuration had no application name, so custom colormaps were saved in a "~/.none" directory shared by all applications, which was created as soon as colormaps were loaded. Their path was moreover computed at import time, so that an application naming PlotPy's configuration afterwards (e.g. "DataLab_v1/plotpy") never got its own custom colormaps. - Name PlotPy's configuration "plotpy" by default - Compute the custom colormaps path on demand, and reload custom colormaps in place each time CONF.set_application is called (CUSTOM_COLORMAPS_PATH remains available, computed on demand) - The first time, copy custom colormaps from the legacy ".none" and ".plotpy" directories, without modifying the legacy files - Do not create the configuration directory on path lookups - Run colormap tests in a temporary configuration directory Closes #70 Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #70: custom colormaps are now stored in the configuration directory of the application, instead of a
~/.nonedirectory shared by all applications.Root cause
plotpy.config.CONFhad no application name, soCONF.get_path()resolved to~/.none(and created it).CUSTOM_COLORMAPS_PATHwas computed once at import time: an application naming PlotPy's configuration afterwards never got its own custom colormaps.As a result, the location depended on the import order. For example, the DataLab application used
~/.plotpy, whereas DataLab scripts and tests used~/.none, and DataLab's intended~/.DataLab_v1/plotpywas never used.Changes
CONFis now aPlotPyUserConfig, named"plotpy"by default:set_application()calls registered callbacks;get_path()no longer creates the configuration directory, which is only created when a file is written.plotpy.mathutils.colormap:get_custom_colormaps_path(), computed on demand (CUSTOM_COLORMAPS_PATHremains available through a module__getattr__);reload_custom_colormaps(), called on eachCONF.set_application(), which updatesCUSTOM_COLORMAPSandALL_COLORMAPSin place (they are imported by name elsewhere);.noneand.plotpydirectories are merged and copied into it. Legacy files are left untouched.test_colormap_config.py, plus anisolated_config_dirfixture so that colormap tests (includingtest_colormap_manager) no longer write into the user's real configuration directory.Resulting locations
~/.none~/.plotpyCONF.set_application("MyApp/plotpy", ...)after import~/.noneor~/.plotpy~/.MyApp/plotpy~/.plotpyor~/.none~/.DataLab_v1/plotpy(
~is~/.configon Linux.)Known limitation
Migration happens once per application, when its file does not exist yet. A user whose
~/.plotpyfile was already written (e.g., by DataLab 1.3) keeps only that file for standalone PlotPy applications: colormaps saved only in~/.noneare not merged into it.Tests
developin an isolated home containing legacy.noneand.plotpyfiles: both the application and the script entry points now load the merged colormaps from~/.DataLab_v1/plotpy.