Skip to content

Commit

Permalink
Merge branch 'main' into typing-animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Feb 13, 2024
2 parents c40b950 + 011c36a commit c31337e
Show file tree
Hide file tree
Showing 19 changed files with 1,036 additions and 951 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
poetry config virtualenvs.prefer-active-python true
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "poetry"
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
$tinyTexPackages = $(python -c "import json;print(' '.join(json.load(open('.github/manimdependency.json'))['windows']['tinytex']))") -Split ' '
$OriPath = $env:PATH
echo "Install Tinytex"
Invoke-WebRequest "https://github.com/yihui/tinytex-releases/releases/download/daily/TinyTeX-1.zip" -O "$($env:TMP)\TinyTex.zip"
Invoke-WebRequest "https://github.com/yihui/tinytex-releases/releases/download/daily/TinyTeX-1.zip" -OutFile "$($env:TMP)\TinyTex.zip"
Expand-Archive -LiteralPath "$($env:TMP)\TinyTex.zip" -DestinationPath "$($PWD)\ManimCache\LatexWindows"
$env:Path = "$($PWD)\ManimCache\LatexWindows\TinyTeX\bin\windows;$($env:PATH)"
tlmgr update --self
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ jobs:
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql.yml
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11

Expand All @@ -30,7 +30,7 @@ jobs:
poetry build
- name: Store artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
name: manim.tar.gz
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-publish-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11

Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
tar -czvf ../html-docs.tar.gz *
- name: Store artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/docs/build/html-docs.tar.gz
name: html-docs.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Basic Concepts
self.add(image, image.background_rectangle)

.. manim:: BooleanOperations
:ref_classes: Union Intersection Exclusion
:ref_classes: Union Intersection Exclusion Difference

class BooleanOperations(Scene):
def construct(self):
Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ modify to your liking. First, run

.. code-block:: sh
docker run -it --name my-manim-container -v "/full/path/to/your/directory:/manim" manimcommunity/manim /bin/bash
docker run -it --name my-manim-container -v "/full/path/to/your/directory:/manim" manimcommunity/manim bash
to obtain an interactive shell inside your container allowing you
Expand Down
2 changes: 2 additions & 0 deletions manim/_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
logging.getLogger("matplotlib").setLevel(logging.INFO)

config = ManimConfig().digest_parser(parser)
# TODO: to be used in the future - see PR #620
# https://github.com/ManimCommunity/manim/pull/620
frame = ManimFrame(config)


Expand Down
14 changes: 8 additions & 6 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from manim import constants
from manim.constants import RendererType
from manim.utils.color import ManimColor
from manim.utils.tex import TexTemplate, TexTemplateFromFile
from manim.utils.tex import TexTemplate

if TYPE_CHECKING:
from enum import EnumMeta
Expand Down Expand Up @@ -833,7 +833,7 @@ def digest_args(self, args: argparse.Namespace) -> Self:

# Handle --tex_template
if args.tex_template:
self.tex_template = TexTemplateFromFile(tex_filename=args.tex_template)
self.tex_template = TexTemplate.from_file(args.tex_template)

if (
self.renderer == RendererType.OPENGL
Expand Down Expand Up @@ -1756,19 +1756,19 @@ def tex_template(self) -> TexTemplate:
if not hasattr(self, "_tex_template") or not self._tex_template:
fn = self._d["tex_template_file"]
if fn:
self._tex_template = TexTemplateFromFile(tex_filename=fn)
self._tex_template = TexTemplate.from_file(fn)
else:
self._tex_template = TexTemplate()
return self._tex_template

@tex_template.setter
def tex_template(self, val: TexTemplateFromFile | TexTemplate) -> None:
if isinstance(val, (TexTemplateFromFile, TexTemplate)):
def tex_template(self, val: TexTemplate) -> None:
if isinstance(val, TexTemplate):
self._tex_template = val

@property
def tex_template_file(self) -> Path:
"""File to read Tex template from (no flag). See :class:`.TexTemplateFromFile`."""
"""File to read Tex template from (no flag). See :class:`.TexTemplate`."""
return self._d["tex_template_file"]

@tex_template_file.setter
Expand All @@ -1793,6 +1793,8 @@ def plugins(self, value: list[str]):
self._d["plugins"] = value


# TODO: to be used in the future - see PR #620
# https://github.com/ManimCommunity/manim/pull/620
class ManimFrame(Mapping):
_OPTS: ClassVar[set[str]] = {
"pixel_width",
Expand Down
15 changes: 7 additions & 8 deletions manim/cli/render/render_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ def validate_resolution(ctx, param, value):
type=Choice(["png", "gif", "mp4", "webm", "mov"], case_sensitive=False),
default=None,
),
option("-s", "--save_last_frame", is_flag=True, default=None),
option(
"-s",
"--save_last_frame",
default=None,
is_flag=True,
help="Render and save only the last frame of a scene as a PNG image.",
),
option(
"-q",
"--quality",
Expand Down Expand Up @@ -123,13 +129,6 @@ def validate_resolution(ctx, param, value):
is_flag=True,
help="Save section videos in addition to movie file.",
),
option(
"-s",
"--save_last_frame",
default=None,
is_flag=True,
help="Save last frame as png (Deprecated).",
),
option(
"-t",
"--transparent",
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/geometry/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def get_arc_center(self, warning: bool = True) -> Point3D:
# For a1 and a2 to lie at the same point arc radius
# must be zero. Thus arc_center will also lie at
# that point.
return a1
return np.copy(a1)
# Tangent vectors
t1 = h1 - a1
t2 = h2 - a2
Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/value_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def construct(self):
self.wait(1)
tracker -= 4
self.wait(0.5)
self.play(tracker.animate.set_value(5)),
self.play(tracker.animate.set_value(5))
self.wait(0.5)
self.play(tracker.animate.set_value(3))
self.play(tracker.animate.increment_value(-2))
Expand Down
2 changes: 2 additions & 0 deletions manim/scene/scene_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@ def flush_cache_directory(self):

def write_subcaption_file(self):
"""Writes the subcaption file."""
if config.output_file is None:
return
subcaption_file = Path(config.output_file).with_suffix(".srt")
subcaption_file.write_text(srt.compose(self.subcaptions), encoding="utf-8")
logger.info(f"Subcaption file has been written as {subcaption_file}")
Expand Down
26 changes: 13 additions & 13 deletions manim/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from __future__ import annotations

from os import PathLike
from typing import Callable, Literal, Union
from typing import Callable, Union

import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -257,9 +257,9 @@
"""

InternalPoint2D_Array: TypeAlias = npt.NDArray[PointDType]
"""``shape: (N, 3)``
"""``shape: (N, 2)``
An array of `Point2D` objects: ``[[float, float], ...]``.
An array of `InternalPoint2D` objects: ``[[float, float], ...]``.
.. note::
This type alias is mostly made available for internal use, and
Expand Down Expand Up @@ -319,7 +319,7 @@
Vector types
"""

Vector2D: TypeAlias = Point2D
Vector2D: TypeAlias = npt.NDArray[PointDType]
"""``shape: (2,)``
A 2-dimensional vector: ``[float, float]``.
Expand All @@ -332,7 +332,7 @@
VMobjects!
"""

Vector2D_Array: TypeAlias = Point2D_Array
Vector2D_Array: TypeAlias = npt.NDArray[PointDType]
"""``shape: (M, 2)``
An array of `Vector2D` objects: ``[[float, float], ...]``.
Expand All @@ -341,7 +341,7 @@
parameter can handle being passed a `Vector3D_Array` instead.
"""

Vector3D: TypeAlias = Point3D
Vector3D: TypeAlias = npt.NDArray[PointDType]
"""``shape: (3,)``
A 3-dimensional vector: ``[float, float, float]``.
Expand All @@ -351,13 +351,13 @@
VMobjects!
"""

Vector3D_Array: TypeAlias = Point3D_Array
Vector3D_Array: TypeAlias = npt.NDArray[PointDType]
"""``shape: (M, 3)``
An array of `Vector3D` objects: ``[[float, float, float], ...]``.
"""

VectorND: TypeAlias = Union[npt.NDArray[PointDType], tuple[float, ...]]
VectorND: TypeAlias = npt.NDArray[PointDType]
"""``shape (N,)``
An :math:`N`-dimensional vector: ``[float, ...]``.
Expand All @@ -368,19 +368,19 @@
collisions.
"""

VectorND_Array: TypeAlias = Union[npt.NDArray[PointDType], tuple[VectorND, ...]]
VectorND_Array: TypeAlias = npt.NDArray[PointDType]
"""``shape (M, N)``
An array of `VectorND` objects: ``[[float, ...], ...]``.
"""

RowVector: TypeAlias = Union[npt.NDArray[PointDType], tuple[tuple[float, ...]]]
RowVector: TypeAlias = npt.NDArray[PointDType]
"""``shape: (1, N)``
A row vector: ``[[float, ...]]``.
"""

ColVector: TypeAlias = Union[npt.NDArray[PointDType], tuple[tuple[float], ...]]
ColVector: TypeAlias = npt.NDArray[PointDType]
"""``shape: (N, 1)``
A column vector: ``[[float], [float], ...]``.
Expand All @@ -392,13 +392,13 @@
Matrix types
"""

MatrixMN: TypeAlias = Union[npt.NDArray[PointDType], tuple[tuple[float, ...], ...]]
MatrixMN: TypeAlias = npt.NDArray[PointDType]
"""``shape: (M, N)``
A matrix: ``[[float, ...], [float, ...], ...]``.
"""

Zeros: TypeAlias = Union[npt.NDArray[PointDType], tuple[tuple[Literal[0], ...], ...]]
Zeros: TypeAlias = MatrixMN
"""``shape: (M, N)``
A `MatrixMN` filled with zeros, typically created with
Expand Down
Loading

0 comments on commit c31337e

Please sign in to comment.