Conversation
…ot_context) Centralized plotting defaults so researchers can set preferences once instead of passing cmap/figsize/dpi to every function call. Supports context manager for temporary overrides and optional TOML config files.
Replace hardcoded cmap/levels defaults with UNSET sentinel and resolve() calls so they respect set_defaults() and plot_context().
…faults Replace hardcoded cmap/levels/figsize/fontsize/colormap defaults with UNSET sentinel and resolve() calls.
…ults Replace hardcoded figsize/cmap/levels with UNSET+resolve() or get_defaults() for inline values.
…ults Replace hardcoded cmap/levels/figsize/dpi defaults with UNSET+resolve() for parameters and get_defaults() for inline values.
Replace hardcoded Plotly colorscale defaults with UNSET+resolve() for parameters and get_defaults() for inline colorscale values.
Tests that set_defaults(), plot_context(), and per-field cmap resolution (cmap, diverging_cmap, sequential_cmap) are correctly picked up by plotting functions.
There was a problem hiding this comment.
Pull request overview
Introduces a centralized global defaults system for plotting/visualization so callers can configure colormaps, sizing, DPI, etc. once (optionally via TOML) and have plotting/animation/interactive helpers pick those up consistently.
Changes:
- Added
cfd_viz.defaultswithPlotDefaults,set_defaults/get_defaults/reset_defaults,plot_context,load_config_file, andUNSET/resolvesentinel-based parameter resolution. - Updated multiple Matplotlib/Plotly plotting and animation entry points to default to
UNSETand resolve from global defaults. - Added a comprehensive test suite validating default behavior, config loading, and that selected plotting functions respect the global defaults.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
cfd_viz/defaults.py |
New global defaults implementation, including TOML config loading and a context manager for temporary overrides. |
cfd_viz/__init__.py |
Re-exports defaults API (set_defaults, plot_context, etc.) at the package root. |
cfd_viz/quick.py |
Uses UNSET + resolve() so figsize comes from global defaults when not explicitly provided. |
cfd_viz/plotting/fields.py |
Resolves levels/cmap from global defaults rather than hard-coded values. |
cfd_viz/plotting/line_plots.py |
Resolves colormap parameters from global defaults. |
cfd_viz/plotting/time_series.py |
Resolves figsize and applies global defaults to some contour plots. |
cfd_viz/plotting/analysis.py |
Resolves figsize/cmap/levels/fontsize from global defaults. |
cfd_viz/interactive/plotly.py |
Resolves Plotly colorscale and uses global defaults in dashboard creation. |
cfd_viz/animation/renderers.py |
Resolves figsize/cmap/levels and applies global defaults in multi-panel animations. |
cfd_viz/animation/export.py |
Resolves figsize/dpi and applies global defaults for colormaps in exports. |
tests/test_defaults.py |
New tests covering defaults API, TOML loading, context manager behavior, and integration with key plotting functions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Calling matplotlib.use("Agg") after importing pyplot can be
ineffective or raise warnings depending on the backend state.
plot_context() now uses a contextvars.ContextVar for context-local overrides instead of mutating and restoring the global _defaults. This prevents concurrent set_defaults() calls from being silently overwritten when the context exits.
…port.py The initial migration missed inline contourf levels in export_frame_to_image and export_analysis_frame, so set_defaults(levels=...) had no effect on exported frames.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
load_config_file() needs a TOML parser but tomllib is only available in Python 3.11+. Add tomli as a fallback for older Python versions.
No description provided.