Refactor MTex

This commit is contained in:
YishiMichael 2022-03-26 20:52:28 +08:00
parent 4a03d196a6
commit 9ac1805e7e
No known key found for this signature in database
GPG key ID: EC615C0C5A86BC80
3 changed files with 489 additions and 473 deletions

File diff suppressed because it is too large Load diff

View file

@ -172,6 +172,8 @@ class SVGMobject(VMobject):
else:
log.warning(f"Unsupported element type: {type(shape)}")
continue
if not mob.has_points():
continue
self.apply_style_to_mobject(mob, shape)
if isinstance(shape, se.Transformable) and shape.apply:
self.handle_transform(mob, shape.transform)

View file

@ -1,6 +1,5 @@
from __future__ import annotations
import itertools as it
from typing import Callable, Iterable, Sequence, TypeVar
import numpy as np
@ -36,10 +35,6 @@ def list_difference_update(l1: Iterable[T], l2: Iterable[T]) -> list[T]:
return [e for e in l1 if e not in l2]
def all_elements_are_instances(iterable: Iterable, Class: type) -> bool:
return all([isinstance(e, Class) for e in iterable])
def adjacent_n_tuples(objects: Iterable[T], n: int) -> zip[tuple[T, T]]:
return zip(*[
[*objects[k:], *objects[:k]]
@ -133,30 +128,6 @@ def make_even(
)
def make_even_by_cycling(
iterable_1: Iterable[T],
iterable_2: Iterable[S]
) -> tuple[list[T], list[S]]:
length = max(len(iterable_1), len(iterable_2))
cycle1 = it.cycle(iterable_1)
cycle2 = it.cycle(iterable_2)
return (
[next(cycle1) for x in range(length)],
[next(cycle2) for x in range(length)]
)
def remove_nones(sequence: Iterable) -> list:
return [x for x in sequence if x]
# Note this is redundant with it.chain
def concatenate_lists(*list_of_lists):
return [item for l in list_of_lists for item in l]
def hash_obj(obj: object) -> int:
if isinstance(obj, dict):
new_obj = {k: hash_obj(v) for k, v in obj.items()}