Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

cleanup and document Container

leotrs782d0597836d
diff --git a/manim/container/container.py b/manim/container/container.py
index f986f1c40..4fe35fb4d 100644
--- a/manim/container/container.py
+++ b/manim/container/container.py
@@ -1,34 +1,30 @@
+"""
+Abstract base class for several objects used by manim. In particular, both
+:class:`~.Scene` and :class:`~.Mobject` inherit from Container.
+"""
+
+from abc import ABC, abstractmethod
from ..utils.config_ops import digest_config
-# Currently, this is only used by both Scene and Mobject.
-# Still, we abstract its functionality here, albeit purely nominally.
-# All actual implementation has to be handled by derived classes for now.
+__all__ = ['Container']
-# TODO: Move the "remove" functionality of Scene to this class
+class Container(ABC):
+ """Abstract base class for several manim objects.
-class Container(object):
- """
- Base class for Scenes and Mobjects. Generic container.
+ Parameters
+ ----------
+ kwargs : :class:`dict`
+ Arguments to be passed to :func:`digest_config`
"""
def __init__(self, **kwargs):
digest_config(self, kwargs)
+ @abstractmethod
def add(self, *items):
- """
- Generic method to add items to Container.
- Must be implemented by subclasses.
- """
- raise Exception(
- "Container.add is not implemented; it is up to derived classes to implement"
- )
+ """Abstract method to add items to Container."""
+ @abstractmethod
def remove(self, *items):
- """
- Generic method to remove items from Container.
- Must be implemented by subclasses.
- """
- raise Exception(
- "Container.remove is not implemented; it is up to derived classes to implement"
- )
+ """Abstract method to remove items from Container."""