diff --git a/doc/sphinxext/math_symbol_table.py b/doc/sphinxext/math_symbol_table.py index a143326ab75b..47028bd12005 100644 --- a/doc/sphinxext/math_symbol_table.py +++ b/doc/sphinxext/math_symbol_table.py @@ -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 @@ -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)) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 6ca472518b65..75cc7616e640 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -511,14 +511,17 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, 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 + if alpha.shape != A.shape[:2]: + raise ValueError("Alpha array shape must match image dimensions") # 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 + #to handle RGBA inputs + if A.shape[2] == 4 and alpha is not None: + A[..., 3] = alpha # override existing alpha channel # Resample in premultiplied alpha space. (TODO: Consider # implementing premultiplied-space resampling in # span_image_resample_rgba_affine::generate?)