feat: add the dark plotting style + font installation#8
feat: add the dark plotting style + font installation#8
Conversation
📝 WalkthroughWalkthroughThis change introduces a dark Matplotlib plotting style and implements a bundled font registration system for the lama_aesthetics library. Font management functions are added to automatically load and register a custom CMU Sans Serif font via importlib.resources. Python minimum version bumped to 3.11. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User Code
participant get_style as get_style()
participant register as register_fonts()
participant importlib as importlib.resources
participant fm as Matplotlib<br/>font_manager
User->>get_style: get_style("dark")
activate get_style
get_style->>register: register_fonts()
activate register
alt First call (guard check)
register->>importlib: Load cmunss.otf<br/>from package
activate importlib
importlib-->>register: Font file bytes
deactivate importlib
register->>fm: Register font with<br/>Matplotlib
activate fm
fm-->>register: Font registered
deactivate fm
Note over register: Set _fonts_registered<br/>= True
else Subsequent calls
Note over register: Skip (already<br/>registered)
end
register-->>get_style: Done
deactivate register
get_style->>get_style: Apply selected style
get_style-->>User: Style with fonts ready
deactivate get_style
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
README.md (1)
4-4: Badge shows unsupported Python versions.The badge indicates support for Python 3.9 and 3.10, but
pyproject.tomlnow requires>=3.11. Update the badge to reflect the new minimum version.-[](https://github.com/lamalab-org/lama-aesthetics/blob/main/pyproject.toml) +[](https://github.com/lamalab-org/lama-aesthetics/blob/main/pyproject.toml)
🧹 Nitpick comments (3)
src/lama_aesthetics/styles/lamalab_dark.mplstyle (2)
1-5: Remove orphaned comments.Lines 1 and 4 contain commented-out color cycle remnants that appear to be development artifacts. Consider removing them for cleaner configuration.
-# '000000', axes.prop_cycle : cycler('color', ['0C5DA5', '00B945', 'FF9500', 'FF2C00', '845B97', '474747', '9e9e9e', "9A607F"]) -#axes.prop_cycle : cycler('color', ["DB444B", "006BA2", "3EBCD2", "379A8B", "EBB434", "#B4BA39", "#9A607F", '#9e9e9e', "#D1B07C"]) -
2-2: Consider consistent color format.The color values mix quote styles (single vs double) and some omit the
#prefix. While Matplotlib accepts both, consistency improves readability.src/lama_aesthetics/aesthetics.py (1)
76-79: Use consistentimportlib.resourcesAPI.
importlib.resources.path()is deprecated since Python 3.11. Since you already use the modern pattern inregister_fonts(), apply the same here for consistency.♻️ Suggested fix
- # Get the file contents as a string - # This will only work for Python 3.7 and later - with importlib.resources.path("lama_aesthetics.styles", style_file) as style_path: + with importlib.resources.as_file(importlib.resources.files("lama_aesthetics.styles").joinpath(style_file)) as style_path: plt.style.use(style_path)
Summary by CodeRabbit
New Features
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.