Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: support alpha array for RGB images in imshow (closes #26092)#30111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Vaishnavi-Raghupathi wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromVaishnavi-Raghupathi:fix-rgb-alpha
Open
Show file tree
Hide file tree
Changes fromall 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
33 changes: 17 additions & 16 deletionsdoc/sphinxext/math_symbol_table.py
View file
Open in desktop
Copy link
Member

Choose a reason for hiding this comment

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

These changes do not belong in this PR.

Original file line numberDiff line numberDiff line change
Expand Up@@ -9,57 +9,57 @@

symbols = [
["Lower-case Greek",
4,
0,
(r"\alpha", r"\beta", r"\gamma", r"\chi", r"\delta", r"\epsilon",
r"\eta", r"\iota", r"\kappa", r"\lambda", r"\mu", r"\nu", r"\omega",
r"\phi", r"\pi", r"\psi", r"\rho", r"\sigma", r"\tau", r"\theta",
r"\upsilon", r"\xi", r"\zeta", r"\digamma", r"\varepsilon", r"\varkappa",
r"\varphi", r"\varpi", r"\varrho", r"\varsigma", r"\vartheta")],
["Upper-case Greek",
4,
0,
(r"\Delta", r"\Gamma", r"\Lambda", r"\Omega", r"\Phi", r"\Pi", r"\Psi",
r"\Sigma", r"\Theta", r"\Upsilon", r"\Xi")],
["Hebrew",
6,
0,
(r"\aleph", r"\beth", r"\gimel", r"\daleth")],
["Latin named characters",
6,
0,
r"""\aa \AA \ae \AE \oe \OE \O \o \thorn \Thorn \ss \eth \dh \DH""".split()],
["Delimiters",
5,
0,
_mathtext.Parser._delims],
["Big symbols",
5,
0,
_mathtext.Parser._overunder_symbols | _mathtext.Parser._dropsub_symbols],
["Standard function names",
5,
0,
{fr"\{fn}" for fn in _mathtext.Parser._function_names}],
["Binary operation symbols",
4,
0,
_mathtext.Parser._binary_operators],
["Relation symbols",
4,
0,
_mathtext.Parser._relation_symbols],
["Arrow symbols",
4,
0,
_mathtext.Parser._arrow_symbols],
["Dot symbols",
4,
0,
r"""\cdots \vdots \ldots \ddots \adots \Colon \therefore \because""".split()],
["Black-board characters",
6,
0,
[fr"\{symbol}" for symbol in _mathtext_data.tex2uni
if re.match(bb_pattern, symbol)]],
["Script characters",
6,
0,
[fr"\{symbol}" for symbol in _mathtext_data.tex2uni
if re.match(scr_pattern, symbol)]],
["Fraktur characters",
6,
0,
[fr"\{symbol}" for symbol in _mathtext_data.tex2uni
if re.match(frak_pattern, symbol)]],
["Miscellaneous symbols",
4,
0,
r"""\neg \infty \forall \wp \exists \bigstar \angle \partial
\nexists \measuredangle \emptyset \sphericalangle \clubsuit
\varnothing \complement \diamondsuit \imath \Finv \triangledown
Expand DownExpand Up@@ -94,7 +94,8 @@ def render_symbol(sym, ignore_variant=False):
sym.startswith(r"\var")),
reverse=(category == "Hebrew")) # Hebrew is rtl
rendered_syms = [f"{render_symbol(sym)} ``{sym}``" for sym in syms]
columns = min(columns, len(syms))
max_columns = 6 # You can adjust this (e.g., 4–8)
columns = min(max_columns, len(syms)) # New dynamic logic
lines.append("**%s**" % category)
lines.append('')
max_width = max(map(len, rendered_syms))
Expand Down
9 changes: 6 additions & 3 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -511,14 +511,17 @@
if alpha is None: # alpha parameter not specified
if A.shape[2] == 3: # image has no alpha channel
A = np.dstack([A, np.ones(A.shape[:2])])
elif np.ndim(alpha) > 0: # Array alpha
elif np.ndim(alpha) > 0: # Array alpha

Check failure on line 514 in lib/matplotlib/image.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Insert at least two spaces before an inline commentRaw Output:message:"Insert at least two spaces before an inline comment" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/image.py" range:{start:{line:514 column:41} end:{line:514 column:42}}} source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E261" url:"https://docs.astral.sh/ruff/rules/too-few-spaces-before-inline-comment"} suggestions:{range:{start:{line:514 column:41} end:{line:514 column:42}} text:" "}
if alpha.shape != A.shape[:2]:
raise ValueError("Alpha array shape must match image dimensions")

Check failure on line 516 in lib/matplotlib/image.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Line too long (95 > 88)Raw Output:message:"Line too long (95 > 88)" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/image.py" range:{start:{line:516 column:89} end:{line:516 column:96}}} source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E501" url:"https://docs.astral.sh/ruff/rules/line-too-long"}

Check failure on line 516 in lib/matplotlib/image.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Trailing whitespaceRaw Output:message:"Trailing whitespace" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/image.py" range:{start:{line:516 column:90} end:{line:516 column:96}}} source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"W291" url:"https://docs.astral.sh/ruff/rules/trailing-whitespace"} suggestions:{range:{start:{line:516 column:90} end:{line:516 column:96}}}

Check warning on line 516 in lib/matplotlib/image.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/image.py#L516

Added line #L516 was not covered by tests
# user-specified array alpha overrides the existing alpha channel
A = np.dstack([A[..., :3], alpha])
else: # Scalar alpha
if A.shape[2] == 3: # broadcast scalar alpha
A = np.dstack([A, np.full(A.shape[:2], alpha, np.float32)])
else: # or apply scalar alpha to existing alpha channel
post_apply_alpha = True
Copy link
Member

Choose a reason for hiding this comment

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

Why is this removed?

#to handle RGBA inputs
if A.shape[2] == 4 and alpha is not None:
A[..., 3] = alpha # override existing alpha channel

Check failure on line 524 in lib/matplotlib/image.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Trailing whitespaceRaw Output:message:"Trailing whitespace" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/image.py" range:{start:{line:524 column:73} end:{line:524 column:85}}} source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"W291" url:"https://docs.astral.sh/ruff/rules/trailing-whitespace"} suggestions:{range:{start:{line:524 column:73} end:{line:524 column:85}}}
Copy link
Member

Choose a reason for hiding this comment

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

I think this is just repeating what already happened on line 518.

# Resample in premultiplied alpha space. (TODO: Consider
# implementing premultiplied-space resampling in
# span_image_resample_rgba_affine::generate?)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp