@@ -38,6 +38,7 @@ def construct(self):
3838
3939
4040import itertools as it
41+ from typing import Iterable , Sequence , Type
4142
4243import numpy as np
4344
@@ -126,48 +127,53 @@ def construct(self):
126127
127128 def __init__ (
128129 self ,
129- matrix ,
130- v_buff = 0.8 ,
131- h_buff = 1.3 ,
132- bracket_h_buff = MED_SMALL_BUFF ,
133- bracket_v_buff = MED_SMALL_BUFF ,
134- add_background_rectangles_to_entries = False ,
135- include_background_rectangle = False ,
136- element_to_mobject = MathTex ,
137- element_to_mobject_config = {},
138- element_alignment_corner = DR ,
139- left_bracket = "[" ,
140- right_bracket = "]" ,
130+ matrix : Iterable ,
131+ v_buff : float = 0.8 ,
132+ h_buff : float = 1.3 ,
133+ bracket_h_buff : float = MED_SMALL_BUFF ,
134+ bracket_v_buff : float = MED_SMALL_BUFF ,
135+ add_background_rectangles_to_entries : bool = False ,
136+ include_background_rectangle : bool = False ,
137+ element_to_mobject : Type [MathTex ] = MathTex ,
138+ element_to_mobject_config : dict = {},
139+ element_alignment_corner : Sequence [float ] = DR ,
140+ left_bracket : str = "[" ,
141+ right_bracket : str = "]" ,
142+ bracket_config : dict = {},
141143 ** kwargs ,
142144 ):
143145 """
144146
145147 Parameters
146148 ----------
147- matrix : :class:`typing.Iterable`
148- A numpy 2d array or list of lists
149- v_buff : :class:`float`, optional
150- vertical buffer, by default 0.8
151- h_buff : :class:`float`, optional
152- horizontal buffer, by default 1.3
153- bracket_h_buff : :class:`float`, optional
154- bracket horizontal buffer, by default MED_SMALL_BUFF
155- bracket_v_buff : :class:`float`, optional
156- bracket vertical buffer, by default MED_SMALL_BUFF
157- add_background_rectangles_to_entries : :class:`bool`, optional
158- `True` if should add backgraound rectangles to entries, by default False
159- include_background_rectangle : :class:`bool`, optional
160- `True` if should include background rectangle, by default False
161- element_to_mobject : :class:`~.Mobject`, optional
162- element to mobject, by default MathTex
163- element_to_mobject_config : Dict[:class:`str`, :class:`~.Mobject`], optional
164- element to mobject config, by default {}
165- element_alignment_corner : :class:`np.ndarray`, optional
166- the element alignment corner, by default DR
167- left_bracket : :class:`str`, optional
168- the left bracket type, by default "["
169- right_bracket : :class:`str`, optional
170- the right bracket type, by default "]"
149+ matrix
150+ A numpy 2d array or list of lists.
151+ v_buff
152+ Vertical distance between elements, by default 0.8.
153+ h_buff
154+ Horizontal distance between elements, by default 1.3.
155+ bracket_h_buff
156+ Distance of the brackets from the matrix, by default ``MED_SMALL_BUFF``.
157+ bracket_v_buff
158+ Height of the brackets, by default ``MED_SMALL_BUFF``.
159+ add_background_rectangles_to_entries
160+ ``True`` if should add backgraound rectangles to entries, by default ``False``.
161+ include_background_rectangle
162+ ``True`` if should include background rectangle, by default ``False``.
163+ element_to_mobject
164+ The mobject class used to construct the elements, by default :class:`~.MathTex`.
165+ element_to_mobject_config
166+ Additional arguments to be passed to the constructor in ``element_to_mobject``,
167+ by default ``{}``.
168+ element_alignment_corner
169+ The corner to which elements are aligned, by default ``DR``.
170+ left_bracket
171+ The left bracket type, by default ``"["``.
172+ right_bracket
173+ The right bracket type, by default ``"]"``.
174+ bracket_config
175+ Additional arguments to be passed to :class:`~.MathTex` when constructing
176+ the brackets.
171177
172178 """
173179
@@ -187,7 +193,7 @@ def __init__(
187193 self .organize_mob_matrix (mob_matrix )
188194 self .elements = VGroup (* it .chain (* mob_matrix ))
189195 self .add (self .elements )
190- self .add_brackets (self .left_bracket , self .right_bracket )
196+ self .add_brackets (self .left_bracket , self .right_bracket , ** bracket_config )
191197 self .center ()
192198 self .mob_matrix = mob_matrix
193199 if self .add_background_rectangles_to_entries :
@@ -217,7 +223,7 @@ def organize_mob_matrix(self, matrix):
217223 )
218224 return self
219225
220- def add_brackets (self , left = "[" , right = "]" ):
226+ def add_brackets (self , left = "[" , right = "]" , ** kwargs ):
221227 """Used internally. Adds the brackets to the Matrix mobject.
222228
223229 See Latex document for various bracket types.
@@ -235,7 +241,7 @@ def add_brackets(self, left="[", right="]"):
235241 The current matrix object (self).
236242 """
237243
238- bracket_pair = MathTex (left , right )
244+ bracket_pair = MathTex (left , right , ** kwargs )
239245 bracket_pair .scale (2 )
240246 bracket_pair .stretch_to_fit_height (self .height + 2 * self .bracket_v_buff )
241247 l_bracket , r_bracket = bracket_pair .split ()
0 commit comments