Refactoring cf-plot to remove duplication and add more pythonic internal structure, include contour animation#123
Refactoring cf-plot to remove duplication and add more pythonic internal structure, include contour animation#123bnlawrence wants to merge 76 commits into
Conversation
… pytest framework
…work through the backlog correctly
… fix for non-float rotated poles
- Use os.path.splitext() instead of string slicing for extension detection - Prevents double .png suffix (.png.png) when file is configured with extension - Example 4 now correctly writes gen_fig_4.png instead of gen_fig_4.png.png
…ookup - Example 6: switch from ggap.nc[3] to ggap_file['geopotential'] - Example 9: switch from ggap.nc[0] to ggap_file['air_temperature'] - Eliminates positional index dependency for all ggap-based tests
- Add /generated-example-images/ to .gitignore - Remove generated-example-images from git index (keep local files)
There was a problem hiding this comment.
Pull request overview
This PR is a major refactor of cf-plot that restructures the monolithic cfplot.py into modular runtime components (layout_runtime, map_runtime, rotated_runtime, state), introduces an object-oriented contour rendering pipeline, removes legacy internal subpackages (graphic, parameters, calculate, utils), migrates testing from unittest to pytest with a new tests/ tree, and adds preliminary contour animation support.
Changes:
- Replaces monolithic state/graphic/parameters modules with
state.py,layout_runtime.py,map_runtime.py,rotated_runtime.py, and an OO contour pipeline; rewritesvector,trajectory,line,stipple, and addsstream. - Introduces contour animation hooks (
animation,animation_axis,animation_title_template, reusable map background) with new unit/integration tests. - Reorganises tests under
tests/unitandtests/integrationwith image comparison against a new reference set; replacessetup.pywith apyproject.tomlbuild configuration and adds extensive developer architecture docs.
Reviewed changes
Copilot reviewed 49 out of 167 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | New PEP 621 metadata; setuptools package list only includes top-level cfplot. |
| setup.py | Removed; build configuration moves to pyproject.toml. |
| README.md | Documents new animation parameters for cfp.con. |
| pytest.ini | Adds pytest config with integration/image markers. |
| cfplot/init.py | Rewrites public surface around new modules; adds version resolution and reset/rgaxes/_mapaxis wrappers. |
| cfplot/state.py | New shared state object with grouped dataclasses, defaults, reset helper. |
| cfplot/layout_runtime.py | New figure/session lifecycle, gset/gpos/gclose/gopen, axis helpers, autosave. |
| cfplot/map_runtime.py | New centralised map setup/axes/title/feature helpers. |
| cfplot/rotated_runtime.py | New rotated-pole rendering and grid axes. |
| cfplot/contour.py | Major contour pipeline rewrite (dataclass + renderer classes + animation hooks). |
| cfplot/blockfill.py / colorbar.py | New helpers extracted from the legacy monolith. |
| cfplot/colour/* | Colour helpers moved/restructured; new colourmaps subpackage. |
| cfplot/vector.py / trajectory.py / line.py / stipple.py / stream.py | Reworked to use new runtime/state modules. |
| cfplot/{graphic,parameters,calculate,utils}/* | Legacy modules deleted/emptied. |
| cfplot/test/test_examples.py | Migrated from unittest to pytest. |
| tests/conftest.py | Adds repo root to sys.path. |
| tests/test_canari.py | Specific regression test; imports a private helper across test packages. |
| tests/integration/* | New integration tests for contour, advanced plots, animation, examples. |
| tests/unit/* | New unit tests for mapaxis, levels, gopen/gclose, state sync, contour boundary, trajectory labels, animation titles. |
| docs/dev/* | New architecture, simplification plan, merge playbook, UML diagrams. |
| .gitignore | Adds .vscode, .DS_Store, generated-example-images. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Note there may be some legacy unit tests (and hence legacy behaviour) which have not been migrated and tested, we should check those ... |
Overall Summary:
Major Technical Changes