Skip to content

feat: add the dark plotting style + font installation#8

Open
MrtinoRG wants to merge 2 commits intomainfrom
maintainance
Open

feat: add the dark plotting style + font installation#8
MrtinoRG wants to merge 2 commits intomainfrom
maintainance

Conversation

@MrtinoRG
Copy link
Collaborator

@MrtinoRG MrtinoRG commented Jan 27, 2026

Summary by CodeRabbit

  • New Features

    • Added a dark plotting style for enhanced visualization options
    • Bundled font support with new functions to register and retrieve font names
  • Chores

    • Updated minimum Python version requirement to 3.11
  • Documentation

    • Updated examples and documentation to showcase the new dark style option

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Configuration & Build Setup
MANIFEST.in, pyproject.toml
Added font file inclusions (\.otf, \.ttf) to manifest and package-data. Bumped requires-python from 3.10 to 3.11.
Documentation
README.md
Updated Styles section and example usage to reflect three plotting styles, including new "dark" option.
Public API
src/lama_aesthetics/__init__.py
Exported two new public functions: get_font_name() and register_fonts().
Font & Style Management
src/lama_aesthetics/aesthetics.py
Implemented font registration mechanism with state guard, register_fonts() function to load cmunss.otf via importlib.resources, get_font_name() helper function, and extended STYLES dict with "dark" entry. Updated get_style() to call register_fonts() before applying styles.
Style Definition
src/lama_aesthetics/styles/lamalab_dark.mplstyle
New dark-theme Matplotlib style configuration with custom color cycle, white-on-dark text rendering, hidden spines, and font settings.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 In shadows deep, a style takes flight,
Bundled fonts glow dark and bright,
Three themes now dance with CMU's grace,
The dark aesthetic finds its place! 🌙✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: introducing a dark plotting style and implementing font installation/registration functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.toml now requires >=3.11. Update the badge to reflect the new minimum version.

-[![Supported Python versions](https://img.shields.io/badge/python-3.9_%7C_3.10_%7C_3.11_%7C_3.12_%7C_3.13-blue?labelColor=grey&color=blue)](https://github.com/lamalab-org/lama-aesthetics/blob/main/pyproject.toml)
+[![Supported Python versions](https://img.shields.io/badge/python-3.11_%7C_3.12_%7C_3.13-blue?labelColor=grey&color=blue)](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 consistent importlib.resources API.

importlib.resources.path() is deprecated since Python 3.11. Since you already use the modern pattern in register_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)

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.

1 participant