🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import re
import typing
from pathlib import Path

import matplotlib.pyplot as plt
from matplotlib.colors import Colormap
from matplotlib.typing import RcKeyType, RcGroupKeyType


def test_cm_stub_matches_runtime_colormaps():
Expand Down Expand Up @@ -30,3 +32,20 @@ def test_cm_stub_matches_runtime_colormaps():
)

assert runtime_cmaps == stubbed_cmaps


def test_rcparam_stubs():
runtime_rc_keys = {
name for name in plt.rcParamsDefault.keys()
if not name.startswith('_')
}

assert {*typing.get_args(RcKeyType)} == runtime_rc_keys

runtime_rc_group_keys = set()
for name in runtime_rc_keys:
groups = name.split('.')
for i in range(1, len(groups)):
runtime_rc_group_keys.add('.'.join(groups[:i]))

assert {*typing.get_args(RcGroupKeyType)} == runtime_rc_group_keys
18 changes: 16 additions & 2 deletions lib/matplotlib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@
"axes.ymargin",
"axes.zmargin",
"axes3d.automargin",
"axes3d.depthshade",
"axes3d.depthshade_minalpha",
"axes3d.grid",
"axes3d.mouserotationstyle",
"axes3d.trackballborder",
Expand Down Expand Up @@ -304,6 +306,7 @@
"figure.titlesize",
"figure.titleweight",
"font.cursive",
"font.enable_last_resort",
"font.family",
"font.fantasy",
"font.monospace",
Expand All @@ -318,6 +321,14 @@
"grid.color",
"grid.linestyle",
"grid.linewidth",
"grid.major.alpha",
"grid.major.color",
"grid.major.linestyle",
"grid.major.linewidth",
"grid.minor.alpha",
"grid.minor.color",
"grid.minor.linestyle",
"grid.minor.linewidth",
"hatch.color",
"hatch.linewidth",
"hist.bins",
Expand Down Expand Up @@ -492,7 +503,7 @@
"ytick.minor.size",
"ytick.minor.visible",
"ytick.minor.width",
"ytick.right"
"ytick.right",
]

RcGroupKeyType: TypeAlias = Literal[
Expand Down Expand Up @@ -524,6 +535,8 @@
"figure.subplot",
"font",
"grid",
"grid.major",
"grid.minor",
"hatch",
"hist",
"image",
Expand All @@ -546,6 +559,7 @@
"scatter",
"svg",
"text",
"text.latex",
"tk",
"webagg",
"xaxis",
Expand All @@ -555,5 +569,5 @@
"yaxis",
"ytick",
"ytick.major",
"ytick.minor"
"ytick.minor",
]
Loading