Skip to content

refactor: reorganize package into subpackages (figure/, axes/, plot1d/, plot2d/, plot3d/, widgets/)#12

Merged
CSSFrancis merged 18 commits into
mainfrom
refactor/project-reorganization
May 12, 2026
Merged

refactor: reorganize package into subpackages (figure/, axes/, plot1d/, plot2d/, plot3d/, widgets/)#12
CSSFrancis merged 18 commits into
mainfrom
refactor/project-reorganization

Conversation

@CSSFrancis
Copy link
Copy Markdown
Owner

Summary

  • Splits the monolithic figure_plots.py (3645 lines) and widgets.py (530 lines) into focused subpackages, following matplotlib's organizational conventions
  • New structure: figure/, axes/, plot1d/, plot2d/, plot3d/, widgets/, _utils.py
  • Public API is unchanged — all existing import anyplotlib and from anyplotlib import ... calls continue to work

New Package Structure

anyplotlib/
├── figure/          ← Figure, GridSpec, SubplotSpec, subplots()
├── axes/            ← Axes, InsetAxes
├── plot1d/          ← Plot1D, Line1D, PlotBar
├── plot2d/          ← Plot2D, PlotMesh
├── plot3d/          ← Plot3D
├── widgets/         ← Widget base + _widgets2d, _widgets1d
├── _utils.py        ← shared helpers (colormap LUT, image encoding, etc.)
├── markers.py       ← unchanged
├── callbacks.py     ← unchanged
└── _repr_utils.py   ← unchanged

Test Plan

  • 752 tests pass, 0 failures (pytest anyplotlib/tests/ -q)
  • All 24 public exports verified (anyplotlib.__all__)
  • No stale imports from old module paths (figure_plots, widgets.py)
  • Benchmark test imports fixed (test_benchmarks_py.py)
  • Example docstring cross-references updated

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2026

Codecov Report

❌ Patch coverage is 86.74699% with 187 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.31%. Comparing base (70d0f42) to head (437b5ef).

Files with missing lines Patch % Lines
anyplotlib/plot1d/_plot1d.py 80.87% 70 Missing ⚠️
anyplotlib/plot1d/_plotbar.py 82.23% 43 Missing ⚠️
anyplotlib/plot2d/_plot2d.py 90.36% 29 Missing ⚠️
anyplotlib/plot3d/_plot3d.py 79.06% 27 Missing ⚠️
anyplotlib/_utils.py 81.96% 11 Missing ⚠️
anyplotlib/axes/_axes.py 95.45% 3 Missing ⚠️
anyplotlib/axes/_inset_axes.py 96.36% 2 Missing ⚠️
anyplotlib/plot2d/_plotmesh.py 96.15% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #12      +/-   ##
==========================================
+ Coverage   77.61%   78.31%   +0.69%     
==========================================
  Files          12       29      +17     
  Lines        2319     2389      +70     
==========================================
+ Hits         1800     1871      +71     
+ Misses        519      518       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

CSSFrancis added 16 commits May 11, 2026 12:35
Moves _LINESTYLE_ALIASES, _arr_to_b64, _norm_linestyle, _normalize_image,
_CMAP_ALIASES, _build_colormap_lut, and _resample_mesh out of figure_plots.py
into a new anyplotlib/_utils.py. Backward-compat re-imports are added to
figure_plots.py so all existing callers continue to work unchanged.
Moves Plot3D and _triangulate_grid out of figure_plots.py into the new
anyplotlib/plot3d/ subpackage. A backward-compat shim in figure_plots.py
re-exports Plot3D so existing imports continue to work.
Addresses code quality review flag: adds one-line docstrings to
anyplotlib/widgets, anyplotlib/plot3d, and anyplotlib/plot2d __init__.py
files. Also updates figure_plots.py docstring to reflect its new role
as a compatibility shim re-exporting classes from dedicated subpackages.
Line1D and Plot1D kept in the same file (_plot1d.py) to avoid circular
imports; figure_plots.py retains backward-compatible re-exports.
Moves Axes and InsetAxes out of figure_plots.py into anyplotlib/axes/_axes.py
and anyplotlib/axes/_inset_axes.py respectively. Also relocates _plot_kind()
to _inset_axes.py where it is used. Backward-compat shims in figure_plots.py
preserve all existing import paths.
Remove unused GridSpec from _figure.py, Union from _gridspec.py, and
Axes from _subplots.py; also fix stale docstring cross-reference in
_subplots.py (figure_plots.Axes → axes.Axes).
…e figure_plots.py shim

Update top-level __init__.py to import directly from axes, plot1d, plot2d,
and plot3d subpackages instead of the figure_plots compat shim. Delete
figure_plots.py and fix all test files that still imported from it.
…mples

Replace all :meth:`~anyplotlib.figure_plots.Plot1D.*` and
:meth:`~anyplotlib.figure_plots.Plot2D.*` Sphinx cross-reference strings
in the Examples directory with the correct new module paths
(anyplotlib.plot1d.Plot1D and anyplotlib.plot2d.Plot2D) following
the project reorganization that deleted figure_plots.py.
@CSSFrancis CSSFrancis force-pushed the refactor/project-reorganization branch from 478c791 to 145be85 Compare May 11, 2026 17:37
@CSSFrancis CSSFrancis merged commit 9853df9 into main May 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants