From f75ed38efafa7a44c71edb9a1ec5f0f94b33743c Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 Date: Sun, 18 Jun 2023 11:38:30 +0300 Subject: [PATCH 1/9] Resolving issue #26092 --- lib/matplotlib/image.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 135934a244a8..9aeb33f3deb1 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -553,9 +553,11 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, else: if A.ndim == 2: # _interpolation_stage == 'rgba' self.norm.autoscale_None(A) - A = self.to_rgba(A) - if A.shape[2] == 3: + A = self.to_rgba(A, alpha=self.get_alpha()) + elif A.shape[2] == 3: A = _rgb_to_rgba(A) + if alpha := self.get_alpha is not None: + A[:, :, 3] = self.get_alpha() alpha = self._get_scalar_alpha() output_alpha = _resample( # resample alpha channel self, A[..., 3], out_shape, t, alpha=alpha) From f673a74ddc1a5f4aef96ce03f1a7a70a77d80874 Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 Date: Mon, 19 Jun 2023 12:40:58 +0300 Subject: [PATCH 2/9] Fixing issue on testing --- lib/matplotlib/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 9aeb33f3deb1..f0f62db2dd82 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -556,7 +556,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, A = self.to_rgba(A, alpha=self.get_alpha()) elif A.shape[2] == 3: A = _rgb_to_rgba(A) - if alpha := self.get_alpha is not None: + if (alpha := self.get_alpha) is not None: A[:, :, 3] = self.get_alpha() alpha = self._get_scalar_alpha() output_alpha = _resample( # resample alpha channel From 568a52332b29ae423c8edd854b5f42e9b36b9f80 Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 <92633955+NikosNikolaidis02@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:19:05 +0300 Subject: [PATCH 3/9] Update image.py --- lib/matplotlib/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index f0f62db2dd82..7755bb419efd 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -557,7 +557,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, elif A.shape[2] == 3: A = _rgb_to_rgba(A) if (alpha := self.get_alpha) is not None: - A[:, :, 3] = self.get_alpha() + A[:, :, 3] = self.get_alpha alpha = self._get_scalar_alpha() output_alpha = _resample( # resample alpha channel self, A[..., 3], out_shape, t, alpha=alpha) From 69c177ccb6f5888038e13b6bc1eaa1b34b6dc7a3 Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 Date: Tue, 20 Jun 2023 20:53:45 +0300 Subject: [PATCH 4/9] Updating testing --- lib/matplotlib/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 7755bb419efd..5b1dd732f0e9 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -556,8 +556,8 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, A = self.to_rgba(A, alpha=self.get_alpha()) elif A.shape[2] == 3: A = _rgb_to_rgba(A) - if (alpha := self.get_alpha) is not None: - A[:, :, 3] = self.get_alpha + if (alpha := self.get_alpha()) is not None: + A[:, :, 3] = self.get_alpha() alpha = self._get_scalar_alpha() output_alpha = _resample( # resample alpha channel self, A[..., 3], out_shape, t, alpha=alpha) From 432036a8468fa7a934d697363b14c9a3f2260715 Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 Date: Mon, 26 Jun 2023 12:58:35 +0300 Subject: [PATCH 5/9] Creating a dynamic way to calculate columns --- doc/sphinxext/math_symbol_table.py | 25 ++++++++++++----------- doc/users/next_whats_new/math_symbols.rst | 5 +++++ 2 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 doc/users/next_whats_new/math_symbols.rst diff --git a/doc/sphinxext/math_symbol_table.py b/doc/sphinxext/math_symbol_table.py index 74b1ac638d73..01fa07990f7b 100644 --- a/doc/sphinxext/math_symbol_table.py +++ b/doc/sphinxext/math_symbol_table.py @@ -5,30 +5,23 @@ symbols = [ ["Lower-case Greek", - 4, (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, (r"\Delta", r"\Gamma", r"\Lambda", r"\Omega", r"\Phi", r"\Pi", r"\Psi", r"\Sigma", r"\Theta", r"\Upsilon", r"\Xi")], ["Hebrew", - 6, (r"\aleph", r"\beth", r"\gimel", r"\daleth")], ["Delimiters", - 5, _mathtext.Parser._delims], ["Big symbols", - 5, _mathtext.Parser._overunder_symbols | _mathtext.Parser._dropsub_symbols], ["Standard function names", - 5, {fr"\{fn}" for fn in _mathtext.Parser._function_names}], ["Binary operation and relation symbols", - 4, r"""\ast \pm \slash \cap \star \mp \cup \cdot \uplus \triangleleft \circ \odot \sqcap \triangleright \bullet \ominus \sqcup \bigcirc \oplus \wedge \diamond \oslash \vee @@ -60,7 +53,6 @@ \Doteq \nsubset \eqcolon \ne """.split()], ["Arrow symbols", - 4, r"""\leftarrow \longleftarrow \uparrow \Leftarrow \Longleftarrow \Uparrow \rightarrow \longrightarrow \downarrow \Rightarrow \Longrightarrow \Downarrow \leftrightarrow \updownarrow @@ -83,7 +75,6 @@ \leftsquigarrow """.split()], ["Miscellaneous symbols", - 4, r"""\neg \infty \forall \wp \exists \bigstar \angle \partial \nexists \measuredangle \eth \emptyset \sphericalangle \clubsuit \varnothing \complement \diamondsuit \imath \Finv \triangledown @@ -106,16 +97,26 @@ def render_symbol(sym, ignore_variant=False): _mathtext.Parser._function_names): sym = chr(_mathtext_data.tex2uni[sym]) return f'\\{sym}' if sym in ('\\', '|') else sym + + def columns_calculation(list): + remainder = max_columns = columns = 10 + max_remainder = 0 + for columns_number in range(max_columns - 1, 3, -1): + remainder = len(list) % columns_number + if remainder > max_remainder: + columns = columns_number + + return columns lines = [] - for category, columns, syms in symbols: + for category, syms in symbols: syms = sorted(syms, # Sort by Unicode and place variants immediately # after standard versions. key=lambda sym: (render_symbol(sym, ignore_variant=True), sym.startswith(r"\var")), reverse=(category == "Hebrew")) # Hebrew is rtl - columns = min(columns, len(syms)) + columns = columns_calculation(syms) lines.append("**%s**" % category) lines.append('') max_width = max(map(len, syms)) * 2 + 16 @@ -168,4 +169,4 @@ def setup(app): print("SYMBOLS NOT IN TABLE:") for sym in _mathtext_data.tex2uni: if sym not in all_symbols: - print(sym) + print(sym) \ No newline at end of file diff --git a/doc/users/next_whats_new/math_symbols.rst b/doc/users/next_whats_new/math_symbols.rst new file mode 100644 index 000000000000..0df7e131f9d9 --- /dev/null +++ b/doc/users/next_whats_new/math_symbols.rst @@ -0,0 +1,5 @@ +``mathtext`` documentation improvements +--------------------------------------- + +The documentation is updated to create all the tables of symbols +by calculating the number of columns in dynamic way in order to have as full of elements rows as possible :ref:`mathtext`. \ No newline at end of file From 99cb86c967163cfba1bda78393c13ec0112db906 Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 Date: Mon, 26 Jun 2023 13:04:09 +0300 Subject: [PATCH 6/9] image.py back to initial --- lib/matplotlib/image.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index edba79316bb8..c8d6f89a0621 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -553,11 +553,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, else: if A.ndim == 2: # _interpolation_stage == 'rgba' self.norm.autoscale_None(A) - A = self.to_rgba(A, alpha=self.get_alpha()) - elif A.shape[2] == 3: + A = self.to_rgba(A) + if A.shape[2] == 3: A = _rgb_to_rgba(A) - if (alpha := self.get_alpha()) is not None: - A[:, :, 3] = self.get_alpha() alpha = self._get_scalar_alpha() output_alpha = _resample( # resample alpha channel self, A[..., 3], out_shape, t, alpha=alpha) From 4b681414eaa7bf0401cac9264933143e57885f44 Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 Date: Mon, 26 Jun 2023 13:13:57 +0300 Subject: [PATCH 7/9] Fixing test failures --- doc/sphinxext/math_symbol_table.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/sphinxext/math_symbol_table.py b/doc/sphinxext/math_symbol_table.py index 01fa07990f7b..b5854680e142 100644 --- a/doc/sphinxext/math_symbol_table.py +++ b/doc/sphinxext/math_symbol_table.py @@ -98,14 +98,14 @@ def render_symbol(sym, ignore_variant=False): sym = chr(_mathtext_data.tex2uni[sym]) return f'\\{sym}' if sym in ('\\', '|') else sym - def columns_calculation(list): + def columns_calculation(my_list): remainder = max_columns = columns = 10 max_remainder = 0 for columns_number in range(max_columns - 1, 3, -1): - remainder = len(list) % columns_number - if remainder > max_remainder: - columns = columns_number - + remainder = len(my_list) % columns_number + if remainder > max_remainder: + columns = columns_number + return columns lines = [] From 50e355b25cd66408c9dd16ffaf3eae1cd8721e60 Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 Date: Mon, 26 Jun 2023 17:29:32 +0300 Subject: [PATCH 8/9] Resolving flake8 conflicts --- doc/sphinxext/math_symbol_table.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/sphinxext/math_symbol_table.py b/doc/sphinxext/math_symbol_table.py index b5854680e142..2355d10dde09 100644 --- a/doc/sphinxext/math_symbol_table.py +++ b/doc/sphinxext/math_symbol_table.py @@ -97,7 +97,7 @@ def render_symbol(sym, ignore_variant=False): _mathtext.Parser._function_names): sym = chr(_mathtext_data.tex2uni[sym]) return f'\\{sym}' if sym in ('\\', '|') else sym - + def columns_calculation(my_list): remainder = max_columns = columns = 10 max_remainder = 0 @@ -105,7 +105,7 @@ def columns_calculation(my_list): remainder = len(my_list) % columns_number if remainder > max_remainder: columns = columns_number - + return columns lines = [] @@ -169,4 +169,4 @@ def setup(app): print("SYMBOLS NOT IN TABLE:") for sym in _mathtext_data.tex2uni: if sym not in all_symbols: - print(sym) \ No newline at end of file + print(sym) From 54a50d9dce646a98ed2227f18358a34d8d057250 Mon Sep 17 00:00:00 2001 From: NikosNikolaidis02 Date: Mon, 26 Jun 2023 17:37:07 +0300 Subject: [PATCH 9/9] Resolving errors on math_symbols.rst --- doc/users/next_whats_new/math_symbols.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/users/next_whats_new/math_symbols.rst b/doc/users/next_whats_new/math_symbols.rst index 0df7e131f9d9..7f5b22dce458 100644 --- a/doc/users/next_whats_new/math_symbols.rst +++ b/doc/users/next_whats_new/math_symbols.rst @@ -1,5 +1,5 @@ ``mathtext`` documentation improvements --------------------------------------- -The documentation is updated to create all the tables of symbols -by calculating the number of columns in dynamic way in order to have as full of elements rows as possible :ref:`mathtext`. \ No newline at end of file +The documentation is updated to create all the tables of symbols +by calculating the number of columns in dynamic way in order to have as full of elements rows as possible :ref:`mathtext`.