Skip to content

Refactor into installable pyncmap package#1

Draft
SminYu wants to merge 2 commits into
mainfrom
codex/refactor-code-for-deployable-library
Draft

Refactor into installable pyncmap package#1
SminYu wants to merge 2 commits into
mainfrom
codex/refactor-code-for-deployable-library

Conversation

@SminYu
Copy link
Copy Markdown
Owner

@SminYu SminYu commented Mar 13, 2026

Motivation

  • Reorganize the repository into a proper Python package so NCL-style *.rgb/*.bound colormaps can be consumed directly from Matplotlib-coded projects.
  • Provide a clearer, more robust API for loading colormaps, handling common input formats, reversing maps, and surfacing actionable errors.

Description

  • Introduce pyncmap package with core implementation in src/pyncmap/core.py exposing ColorMapMaker, get_colormap, and list_available_colormaps, and define ColormapFileError for missing resources.
  • Implement robust RGB parsing, automatic 0–1 normalization (detects 0–255 or 0–1 inputs), _r-suffix reverse support, and BoundaryNorm creation via .norm and .boundaries properties.
  • Package example colormap data under src/pyncmap/cmap_data/ and add project metadata and packaging configuration in pyproject.toml with package-data to include the *.rgb/*.bound files.
  • Add convenience backward-compatible shim ncl_colormap.py, tests in tests/test_core.py, updated README.md, LICENSE, and a .gitignore for developer hygiene.

Testing

  • Ran python -m compileall src ncl_colormap.py tests which completed successfully.
  • Ran PYTHONPATH=src pytest -q which failed to collect/run because numpy is not installed in this environment (tests require numpy and matplotlib).
  • Attempted python -m pip install -e . which failed in this environment due to inability to fetch build dependencies (setuptools>=68) from the package index because of network/proxy restrictions.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant