@@ -259,7 +259,7 @@ def __init__(
259259 * tex_strings : str ,
260260 arg_separator : str = " " ,
261261 substrings_to_isolate : Iterable [str ] | None = None ,
262- tex_to_color_map : dict [str , ManimColor ] | None = None ,
262+ tex_to_color_map : dict [str , ParsableManimColor ] | None = None ,
263263 tex_environment : str | None = "align*" ,
264264 ** kwargs : Any ,
265265 ):
@@ -269,7 +269,7 @@ def __init__(
269269 [] if substrings_to_isolate is None else substrings_to_isolate
270270 )
271271 if tex_to_color_map is None :
272- self .tex_to_color_map : dict [str , ManimColor ] = {}
272+ self .tex_to_color_map : dict [str , ParsableManimColor ] = {}
273273 else :
274274 self .tex_to_color_map = tex_to_color_map
275275 self .tex_environment = tex_environment
@@ -416,17 +416,17 @@ def set_opacity_by_tex(
416416 return self
417417
418418 def set_color_by_tex_to_color_map (
419- self , texs_to_color_map : dict [str , ManimColor ], ** kwargs : Any
419+ self , texs_to_color_map : dict [str , ParsableManimColor ], ** kwargs : Any
420420 ) -> Self :
421421 for texs , color in list (texs_to_color_map .items ()):
422422 try :
423423 # If the given key behaves like tex_strings
424424 texs + ""
425- self .set_color_by_tex (texs , color , ** kwargs )
425+ self .set_color_by_tex (texs , ManimColor ( color ) , ** kwargs )
426426 except TypeError :
427427 # If the given key is a tuple
428428 for tex in texs :
429- self .set_color_by_tex (tex , color , ** kwargs )
429+ self .set_color_by_tex (tex , ManimColor ( color ) , ** kwargs )
430430 return self
431431
432432 def index_of_part (self , part : MathTex ) -> int :
@@ -508,7 +508,9 @@ def __init__(
508508 self .tex_environment = tex_environment
509509 line_separated_items = [s + "\\ \\ " for s in items ]
510510 super ().__init__ (
511- * line_separated_items , tex_environment = tex_environment , ** kwargs
511+ * line_separated_items ,
512+ tex_environment = tex_environment ,
513+ ** kwargs ,
512514 )
513515 for part in self :
514516 dot = MathTex ("\\ cdot" ).scale (self .dot_scale_factor )
@@ -519,9 +521,13 @@ def __init__(
519521 def fade_all_but (self , index_or_string : int | str , opacity : float = 0.5 ) -> None :
520522 arg = index_or_string
521523 if isinstance (arg , str ):
522- part = self .get_part_by_tex (arg )
524+ part : VGroup | VMobject | None = self .get_part_by_tex (arg )
525+ if part is None :
526+ raise Exception (
527+ f"Could not locate part by provided tex string '{ arg } '."
528+ )
523529 elif isinstance (arg , int ):
524- part = self .submobjects [arg ] # type: ignore[assignment]
530+ part = self .submobjects [arg ]
525531 else :
526532 raise TypeError (f"Expected int or string, got { arg } " )
527533 for other_part in self .submobjects :
0 commit comments