mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 22:07:51 +00:00
Some small refactors
This commit is contained in:
parent
a6675eb043
commit
725155409b
1 changed files with 4 additions and 13 deletions
|
|
@ -237,7 +237,7 @@ class _TexParser(object):
|
||||||
f"\"{tex_string[slice(*span_tuple)]}\""
|
f"\"{tex_string[slice(*span_tuple)]}\""
|
||||||
for span_tuple in span_tuple_pair
|
for span_tuple in span_tuple_pair
|
||||||
))
|
))
|
||||||
sys.exit(2)
|
raise ValueError
|
||||||
|
|
||||||
def analyse_containing_labels(self):
|
def analyse_containing_labels(self):
|
||||||
for span_0, tex_span_0 in self.tex_spans_dict.items():
|
for span_0, tex_span_0 in self.tex_spans_dict.items():
|
||||||
|
|
@ -299,8 +299,7 @@ class _TexParser(object):
|
||||||
return result.replace(color_command_placeholder, "\\color[RGB]")
|
return result.replace(color_command_placeholder, "\\color[RGB]")
|
||||||
|
|
||||||
def raise_tex_parsing_error(self, message):
|
def raise_tex_parsing_error(self, message):
|
||||||
log.error(f"Failed to parse tex ({message}): \"{self.tex_string}\"")
|
raise ValueError(f"Failed to parse tex ({message}): \"{self.tex_string}\"")
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_color_related_commands_dict():
|
def get_color_related_commands_dict():
|
||||||
|
|
@ -581,8 +580,7 @@ class MTex(VMobject):
|
||||||
span_tuples = self.find_span_components_of_custom_span(custom_span_tuple)
|
span_tuples = self.find_span_components_of_custom_span(custom_span_tuple)
|
||||||
if span_tuples is None:
|
if span_tuples is None:
|
||||||
tex = self.tex_string[slice(*custom_span_tuple)]
|
tex = self.tex_string[slice(*custom_span_tuple)]
|
||||||
log.error(f"Failed to get span of tex: \"{tex}\"")
|
raise ValueError(f"Failed to get span of tex: \"{tex}\"")
|
||||||
sys.exit(2)
|
|
||||||
return self.get_part_by_span_tuples(span_tuples)
|
return self.get_part_by_span_tuples(span_tuples)
|
||||||
|
|
||||||
def get_parts_by_tex(self, tex):
|
def get_parts_by_tex(self, tex):
|
||||||
|
|
@ -613,20 +611,13 @@ class MTex(VMobject):
|
||||||
if submob in part
|
if submob in part
|
||||||
]
|
]
|
||||||
if not indices:
|
if not indices:
|
||||||
log.error("Failed to find part in tex")
|
raise ValueError("Failed to find part in tex")
|
||||||
sys.exit(2)
|
|
||||||
return indices
|
return indices
|
||||||
|
|
||||||
def indices_of_part_by_tex(self, tex, index=0):
|
def indices_of_part_by_tex(self, tex, index=0):
|
||||||
part = self.get_part_by_tex(tex, index=index)
|
part = self.get_part_by_tex(tex, index=index)
|
||||||
return self.indices_of_part(part)
|
return self.indices_of_part(part)
|
||||||
|
|
||||||
def indices_of_all_parts_by_tex(self, tex, index=0):
|
|
||||||
all_parts = self.get_parts_by_tex(tex)
|
|
||||||
return list(it.chain(*[
|
|
||||||
self.indices_of_part(part) for part in all_parts
|
|
||||||
]))
|
|
||||||
|
|
||||||
def range_of_part(self, part):
|
def range_of_part(self, part):
|
||||||
indices = self.indices_of_part(part)
|
indices = self.indices_of_part(part)
|
||||||
return range(indices[0], indices[-1] + 1)
|
return range(indices[0], indices[-1] + 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue