manim 0.18.0.post0__py3-none-any.whl → 0.19.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of manim might be problematic. Click here for more details.

Files changed (146) hide show
  1. manim/__init__.py +3 -6
  2. manim/__main__.py +61 -20
  3. manim/_config/__init__.py +6 -3
  4. manim/_config/cli_colors.py +16 -8
  5. manim/_config/default.cfg +1 -3
  6. manim/_config/logger_utils.py +14 -8
  7. manim/_config/utils.py +651 -472
  8. manim/animation/animation.py +152 -5
  9. manim/animation/composition.py +80 -39
  10. manim/animation/creation.py +196 -14
  11. manim/animation/fading.py +5 -9
  12. manim/animation/indication.py +103 -47
  13. manim/animation/movement.py +22 -5
  14. manim/animation/rotation.py +3 -2
  15. manim/animation/specialized.py +4 -6
  16. manim/animation/speedmodifier.py +10 -5
  17. manim/animation/transform.py +4 -5
  18. manim/animation/transform_matching_parts.py +1 -1
  19. manim/animation/updaters/mobject_update_utils.py +17 -14
  20. manim/camera/camera.py +15 -6
  21. manim/cli/__init__.py +17 -0
  22. manim/cli/cfg/group.py +70 -44
  23. manim/cli/checkhealth/checks.py +93 -75
  24. manim/cli/checkhealth/commands.py +14 -5
  25. manim/cli/default_group.py +157 -25
  26. manim/cli/init/commands.py +32 -24
  27. manim/cli/plugins/commands.py +16 -3
  28. manim/cli/render/commands.py +72 -60
  29. manim/cli/render/ease_of_access_options.py +4 -3
  30. manim/cli/render/global_options.py +51 -15
  31. manim/cli/render/output_options.py +6 -5
  32. manim/cli/render/render_options.py +97 -32
  33. manim/constants.py +65 -19
  34. manim/gui/gui.py +2 -0
  35. manim/mobject/frame.py +0 -1
  36. manim/mobject/geometry/arc.py +112 -78
  37. manim/mobject/geometry/boolean_ops.py +32 -25
  38. manim/mobject/geometry/labeled.py +300 -77
  39. manim/mobject/geometry/line.py +132 -64
  40. manim/mobject/geometry/polygram.py +126 -30
  41. manim/mobject/geometry/shape_matchers.py +35 -15
  42. manim/mobject/geometry/tips.py +38 -29
  43. manim/mobject/graph.py +414 -133
  44. manim/mobject/graphing/coordinate_systems.py +126 -64
  45. manim/mobject/graphing/functions.py +25 -15
  46. manim/mobject/graphing/number_line.py +24 -10
  47. manim/mobject/graphing/probability.py +2 -10
  48. manim/mobject/graphing/scale.py +6 -5
  49. manim/mobject/matrix.py +17 -19
  50. manim/mobject/mobject.py +314 -165
  51. manim/mobject/opengl/opengl_compatibility.py +2 -0
  52. manim/mobject/opengl/opengl_geometry.py +30 -9
  53. manim/mobject/opengl/opengl_image_mobject.py +2 -0
  54. manim/mobject/opengl/opengl_mobject.py +509 -343
  55. manim/mobject/opengl/opengl_point_cloud_mobject.py +5 -7
  56. manim/mobject/opengl/opengl_surface.py +3 -2
  57. manim/mobject/opengl/opengl_three_dimensions.py +2 -0
  58. manim/mobject/opengl/opengl_vectorized_mobject.py +46 -79
  59. manim/mobject/svg/brace.py +63 -13
  60. manim/mobject/svg/svg_mobject.py +4 -3
  61. manim/mobject/table.py +11 -13
  62. manim/mobject/text/code_mobject.py +186 -548
  63. manim/mobject/text/numbers.py +9 -7
  64. manim/mobject/text/tex_mobject.py +23 -14
  65. manim/mobject/text/text_mobject.py +70 -24
  66. manim/mobject/three_d/polyhedra.py +98 -1
  67. manim/mobject/three_d/three_d_utils.py +4 -4
  68. manim/mobject/three_d/three_dimensions.py +62 -34
  69. manim/mobject/types/image_mobject.py +42 -24
  70. manim/mobject/types/point_cloud_mobject.py +105 -67
  71. manim/mobject/types/vectorized_mobject.py +496 -228
  72. manim/mobject/value_tracker.py +5 -4
  73. manim/mobject/vector_field.py +5 -5
  74. manim/opengl/__init__.py +3 -3
  75. manim/plugins/__init__.py +14 -1
  76. manim/plugins/plugins_flags.py +14 -8
  77. manim/renderer/cairo_renderer.py +20 -10
  78. manim/renderer/opengl_renderer.py +21 -23
  79. manim/renderer/opengl_renderer_window.py +2 -0
  80. manim/renderer/shader.py +2 -3
  81. manim/renderer/shader_wrapper.py +5 -2
  82. manim/renderer/vectorized_mobject_rendering.py +5 -0
  83. manim/scene/moving_camera_scene.py +23 -0
  84. manim/scene/scene.py +90 -43
  85. manim/scene/scene_file_writer.py +316 -165
  86. manim/scene/section.py +17 -15
  87. manim/scene/three_d_scene.py +13 -21
  88. manim/scene/vector_space_scene.py +22 -9
  89. manim/typing.py +830 -70
  90. manim/utils/bezier.py +1667 -399
  91. manim/utils/caching.py +13 -5
  92. manim/utils/color/AS2700.py +2 -0
  93. manim/utils/color/BS381.py +3 -0
  94. manim/utils/color/DVIPSNAMES.py +96 -0
  95. manim/utils/color/SVGNAMES.py +179 -0
  96. manim/utils/color/X11.py +3 -0
  97. manim/utils/color/XKCD.py +3 -0
  98. manim/utils/color/__init__.py +8 -5
  99. manim/utils/color/core.py +844 -309
  100. manim/utils/color/manim_colors.py +7 -9
  101. manim/utils/commands.py +48 -20
  102. manim/utils/config_ops.py +18 -13
  103. manim/utils/debug.py +8 -7
  104. manim/utils/deprecation.py +90 -40
  105. manim/utils/docbuild/__init__.py +17 -0
  106. manim/utils/docbuild/autoaliasattr_directive.py +234 -0
  107. manim/utils/docbuild/autocolor_directive.py +21 -17
  108. manim/utils/docbuild/manim_directive.py +50 -35
  109. manim/utils/docbuild/module_parsing.py +245 -0
  110. manim/utils/exceptions.py +6 -0
  111. manim/utils/family.py +5 -3
  112. manim/utils/family_ops.py +17 -4
  113. manim/utils/file_ops.py +26 -16
  114. manim/utils/hashing.py +9 -7
  115. manim/utils/images.py +10 -4
  116. manim/utils/ipython_magic.py +14 -8
  117. manim/utils/iterables.py +161 -119
  118. manim/utils/module_ops.py +57 -19
  119. manim/utils/opengl.py +83 -24
  120. manim/utils/parameter_parsing.py +32 -0
  121. manim/utils/paths.py +21 -23
  122. manim/utils/polylabel.py +168 -0
  123. manim/utils/qhull.py +218 -0
  124. manim/utils/rate_functions.py +74 -39
  125. manim/utils/simple_functions.py +24 -15
  126. manim/utils/sounds.py +7 -1
  127. manim/utils/space_ops.py +125 -69
  128. manim/utils/testing/__init__.py +17 -0
  129. manim/utils/testing/_frames_testers.py +13 -8
  130. manim/utils/testing/_show_diff.py +5 -3
  131. manim/utils/testing/_test_class_makers.py +33 -18
  132. manim/utils/testing/frames_comparison.py +27 -19
  133. manim/utils/tex.py +127 -197
  134. manim/utils/tex_file_writing.py +47 -45
  135. manim/utils/tex_templates.py +2 -1
  136. manim/utils/unit.py +6 -5
  137. {manim-0.18.0.post0.dist-info → manim-0.19.0.dist-info}/LICENSE.community +1 -1
  138. {manim-0.18.0.post0.dist-info → manim-0.19.0.dist-info}/METADATA +40 -39
  139. manim-0.19.0.dist-info/RECORD +221 -0
  140. {manim-0.18.0.post0.dist-info → manim-0.19.0.dist-info}/WHEEL +1 -1
  141. manim/cli/new/__init__.py +0 -0
  142. manim/cli/new/group.py +0 -189
  143. manim/plugins/import_plugins.py +0 -43
  144. manim-0.18.0.post0.dist-info/RECORD +0 -217
  145. {manim-0.18.0.post0.dist-info → manim-0.19.0.dist-info}/LICENSE +0 -0
  146. {manim-0.18.0.post0.dist-info → manim-0.19.0.dist-info}/entry_points.txt +0 -0
@@ -2,15 +2,18 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from manim.mobject.mobject import Mobject
5
6
  from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject
6
7
 
7
8
  __all__ = ["NumberLine", "UnitInterval"]
8
9
 
9
10
 
10
- from typing import TYPE_CHECKING, Callable, Iterable, Sequence
11
+ from collections.abc import Iterable, Sequence
12
+ from typing import TYPE_CHECKING, Callable
11
13
 
12
14
  if TYPE_CHECKING:
13
15
  from manim.mobject.geometry.tips import ArrowTip
16
+ from manim.typing import Point3DLike
14
17
 
15
18
  import numpy as np
16
19
 
@@ -274,7 +277,8 @@ class NumberLine(Line):
274
277
 
275
278
  def add_ticks(self):
276
279
  """Adds ticks to the number line. Ticks can be accessed after creation
277
- via ``self.ticks``."""
280
+ via ``self.ticks``.
281
+ """
278
282
  ticks = VGroup()
279
283
  elongated_tick_size = self.tick_size * self.longer_tick_multiple
280
284
  elongated_tick_offsets = self.numbers_with_elongated_ticks - self.x_min
@@ -343,6 +347,7 @@ class NumberLine(Line):
343
347
  def number_to_point(self, number: float | np.ndarray) -> np.ndarray:
344
348
  """Accepts a value along the number line and returns a point with
345
349
  respect to the scene.
350
+ Equivalent to `NumberLine @ number`
346
351
 
347
352
  Parameters
348
353
  ----------
@@ -363,7 +368,9 @@ class NumberLine(Line):
363
368
  array([0., 0., 0.])
364
369
  >>> number_line.number_to_point(1)
365
370
  array([1., 0., 0.])
366
- >>> number_line.number_to_point([1,2,3])
371
+ >>> number_line @ 1
372
+ array([1., 0., 0.])
373
+ >>> number_line.number_to_point([1, 2, 3])
367
374
  array([[1., 0., 0.],
368
375
  [2., 0., 0.],
369
376
  [3., 0., 0.]])
@@ -395,11 +402,11 @@ class NumberLine(Line):
395
402
 
396
403
  >>> from manim import NumberLine
397
404
  >>> number_line = NumberLine()
398
- >>> number_line.point_to_number((0,0,0))
399
- 0.0
400
- >>> number_line.point_to_number((1,0,0))
401
- 1.0
402
- >>> number_line.point_to_number([[0.5,0,0],[1,0,0],[1.5,0,0]])
405
+ >>> number_line.point_to_number((0, 0, 0))
406
+ np.float64(0.0)
407
+ >>> number_line.point_to_number((1, 0, 0))
408
+ np.float64(1.0)
409
+ >>> number_line.point_to_number([[0.5, 0, 0], [1, 0, 0], [1.5, 0, 0]])
403
410
  array([0.5, 1. , 1.5])
404
411
 
405
412
  """
@@ -475,7 +482,7 @@ class NumberLine(Line):
475
482
  num_mob.next_to(self.number_to_point(x), direction=direction, buff=buff)
476
483
  if x < 0 and self.label_direction[0] == 0:
477
484
  # Align without the minus sign
478
- num_mob.shift(num_mob[0].get_width() * LEFT / 2)
485
+ num_mob.shift(num_mob[0].width * LEFT / 2)
479
486
  return num_mob
480
487
 
481
488
  def get_number_mobjects(self, *numbers, **kwargs) -> VGroup:
@@ -574,7 +581,6 @@ class NumberLine(Line):
574
581
  AttributeError
575
582
  If the label does not have a ``font_size`` attribute, an ``AttributeError`` is raised.
576
583
  """
577
-
578
584
  direction = self.label_direction if direction is None else direction
579
585
  buff = self.line_to_number_buff if buff is None else buff
580
586
  font_size = self.font_size if font_size is None else font_size
@@ -641,6 +647,14 @@ class NumberLine(Line):
641
647
  return 0
642
648
  return len(step.split(".")[-1])
643
649
 
650
+ def __matmul__(self, other: float):
651
+ return self.n2p(other)
652
+
653
+ def __rmatmul__(self, other: Point3DLike | Mobject):
654
+ if isinstance(other, Mobject):
655
+ other = other.get_center()
656
+ return self.p2n(other)
657
+
644
658
 
645
659
  class UnitInterval(NumberLine):
646
660
  def __init__(
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  __all__ = ["SampleSpace", "BarChart"]
6
6
 
7
7
 
8
- from typing import Iterable, MutableSequence, Sequence
8
+ from collections.abc import Iterable, MutableSequence, Sequence
9
9
 
10
10
  import numpy as np
11
11
 
@@ -319,7 +319,6 @@ class BarChart(Axes):
319
319
  Primarily used when the bars are initialized with ``self._add_bars``
320
320
  or updated via ``self.change_bar_values``.
321
321
  """
322
-
323
322
  self.bars.set_color_by_gradient(*self.bar_colors)
324
323
 
325
324
  def _add_x_axis_labels(self):
@@ -329,7 +328,6 @@ class BarChart(Axes):
329
328
 
330
329
  UP for negative values and DOWN for positive values.
331
330
  """
332
-
333
331
  val_range = np.arange(
334
332
  0.5, len(self.bar_names), 1
335
333
  ) # 0.5 shifted so that labels are centered, not on ticks
@@ -339,10 +337,7 @@ class BarChart(Axes):
339
337
  for i, (value, bar_name) in enumerate(zip(val_range, self.bar_names)):
340
338
  # to accommodate negative bars, the label may need to be
341
339
  # below or above the x_axis depending on the value of the bar
342
- if self.values[i] < 0:
343
- direction = UP
344
- else:
345
- direction = DOWN
340
+ direction = UP if self.values[i] < 0 else DOWN
346
341
  bar_name_label = self.x_axis.label_constructor(bar_name)
347
342
 
348
343
  bar_name_label.font_size = self.x_axis.font_size
@@ -372,7 +367,6 @@ class BarChart(Axes):
372
367
  Rectangle
373
368
  A positioned rectangle representing a bar on the chart.
374
369
  """
375
-
376
370
  # bar measurements relative to the axis
377
371
 
378
372
  # distance from between the y-axis and the top of the bar
@@ -435,7 +429,6 @@ class BarChart(Axes):
435
429
 
436
430
  self.add(chart, c_bar_lbls)
437
431
  """
438
-
439
432
  bar_labels = VGroup()
440
433
  for bar, value in zip(self.bars, self.values):
441
434
  bar_lbl = label_constructor(str(value))
@@ -483,7 +476,6 @@ class BarChart(Axes):
483
476
  chart.change_bar_values(list(reversed(values)))
484
477
  self.add(chart.get_bar_labels(font_size=24))
485
478
  """
486
-
487
479
  for i, (bar, value) in enumerate(zip(self.bars, values)):
488
480
  chart_val = self.values[i]
489
481
 
@@ -1,7 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import math
4
- from typing import TYPE_CHECKING, Any, Iterable
4
+ from collections.abc import Iterable
5
+ from typing import TYPE_CHECKING, Any
5
6
 
6
7
  import numpy as np
7
8
 
@@ -89,7 +90,6 @@ class LinearBase(_ScaleBase):
89
90
  scale_factor
90
91
  The slope of the linear function, by default 1.0
91
92
  """
92
-
93
93
  super().__init__()
94
94
  self.scale_factor = scale_factor
95
95
 
@@ -145,7 +145,9 @@ class LogBase(_ScaleBase):
145
145
  """Inverse of ``function``. The value must be greater than 0"""
146
146
  if isinstance(value, np.ndarray):
147
147
  condition = value.any() <= 0
148
- func = lambda value, base: np.log(value) / np.log(base)
148
+
149
+ def func(value, base):
150
+ return np.log(value) / np.log(base)
149
151
  else:
150
152
  condition = value <= 0
151
153
  func = math.log
@@ -174,12 +176,11 @@ class LogBase(_ScaleBase):
174
176
  base_config
175
177
  Additional arguments to be passed to :class:`~.Integer`.
176
178
  """
177
-
178
179
  # uses `format` syntax to control the number of decimal places.
179
180
  tex_labels = [
180
181
  Integer(
181
182
  self.base,
182
- unit="^{%s}" % (f"{self.inverse_function(i):.{unit_decimal_places}f}"),
183
+ unit="^{%s}" % (f"{self.inverse_function(i):.{unit_decimal_places}f}"), # noqa: UP031
183
184
  **base_config,
184
185
  )
185
186
  for i in val_range
manim/mobject/matrix.py CHANGED
@@ -15,8 +15,8 @@ Examples
15
15
  m2 = DecimalMatrix(
16
16
  [[3.456, 2.122], [33.2244, 12.33]],
17
17
  element_to_mobject_config={"num_decimal_places": 2},
18
- left_bracket="\\{",
19
- right_bracket="\\}")
18
+ left_bracket=r"\{",
19
+ right_bracket=r"\}")
20
20
  m3 = MobjectMatrix(
21
21
  [[Circle().scale(0.3), Square().scale(0.3)],
22
22
  [MathTex("\\pi").scale(2), Star().scale(0.3)]],
@@ -40,7 +40,7 @@ __all__ = [
40
40
 
41
41
 
42
42
  import itertools as it
43
- from typing import Iterable, Sequence
43
+ from collections.abc import Iterable, Sequence
44
44
 
45
45
  import numpy as np
46
46
 
@@ -72,7 +72,7 @@ def matrix_to_mobject(matrix):
72
72
 
73
73
 
74
74
  class Matrix(VMobject, metaclass=ConvertToOpenGL):
75
- """A mobject that displays a matrix on the screen.
75
+ r"""A mobject that displays a matrix on the screen.
76
76
 
77
77
  Parameters
78
78
  ----------
@@ -118,22 +118,22 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
118
118
 
119
119
  class MatrixExamples(Scene):
120
120
  def construct(self):
121
- m0 = Matrix([[2, "\\pi"], [-1, 1]])
121
+ m0 = Matrix([[2, r"\pi"], [-1, 1]])
122
122
  m1 = Matrix([[2, 0, 4], [-1, 1, 5]],
123
123
  v_buff=1.3,
124
124
  h_buff=0.8,
125
125
  bracket_h_buff=SMALL_BUFF,
126
126
  bracket_v_buff=SMALL_BUFF,
127
- left_bracket="\\{",
128
- right_bracket="\\}")
127
+ left_bracket=r"\{",
128
+ right_bracket=r"\}")
129
129
  m1.add(SurroundingRectangle(m1.get_columns()[1]))
130
130
  m2 = Matrix([[2, 1], [-1, 3]],
131
131
  element_alignment_corner=UL,
132
132
  left_bracket="(",
133
133
  right_bracket=")")
134
134
  m3 = Matrix([[2, 1], [-1, 3]],
135
- left_bracket="\\\\langle",
136
- right_bracket="\\\\rangle")
135
+ left_bracket=r"\langle",
136
+ right_bracket=r"\rangle")
137
137
  m4 = Matrix([[2, 1], [-1, 3]],
138
138
  ).set_column_colors(RED, GREEN)
139
139
  m5 = Matrix([[2, 1], [-1, 3]],
@@ -241,7 +241,6 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
241
241
  :class:`Matrix`
242
242
  The current matrix object (self).
243
243
  """
244
-
245
244
  # Height per row of LaTeX array with default settings
246
245
  BRACKET_HEIGHT = 0.5977
247
246
 
@@ -280,7 +279,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
280
279
  return self
281
280
 
282
281
  def get_columns(self):
283
- """Return columns of the matrix as VGroups.
282
+ r"""Return columns of the matrix as VGroups.
284
283
 
285
284
  Returns
286
285
  --------
@@ -295,11 +294,10 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
295
294
 
296
295
  class GetColumnsExample(Scene):
297
296
  def construct(self):
298
- m0 = Matrix([["\\pi", 3], [1, 5]])
297
+ m0 = Matrix([[r"\pi", 3], [1, 5]])
299
298
  m0.add(SurroundingRectangle(m0.get_columns()[1]))
300
299
  self.add(m0)
301
300
  """
302
-
303
301
  return VGroup(
304
302
  *(
305
303
  VGroup(*(row[i] for row in self.mob_matrix))
@@ -308,7 +306,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
308
306
  )
309
307
 
310
308
  def set_column_colors(self, *colors: str):
311
- """Set individual colors for each columns of the matrix.
309
+ r"""Set individual colors for each columns of the matrix.
312
310
 
313
311
  Parameters
314
312
  ----------
@@ -338,7 +336,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
338
336
  return self
339
337
 
340
338
  def get_rows(self):
341
- """Return rows of the matrix as VGroups.
339
+ r"""Return rows of the matrix as VGroups.
342
340
 
343
341
  Returns
344
342
  --------
@@ -360,7 +358,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
360
358
  return VGroup(*(VGroup(*row) for row in self.mob_matrix))
361
359
 
362
360
  def set_row_colors(self, *colors: str):
363
- """Set individual colors for each row of the matrix.
361
+ r"""Set individual colors for each row of the matrix.
364
362
 
365
363
  Parameters
366
364
  ----------
@@ -438,7 +436,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
438
436
  return self.elements
439
437
 
440
438
  def get_brackets(self):
441
- """Return the bracket mobjects.
439
+ r"""Return the bracket mobjects.
442
440
 
443
441
  Returns
444
442
  --------
@@ -464,7 +462,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
464
462
 
465
463
 
466
464
  class DecimalMatrix(Matrix):
467
- """A mobject that displays a matrix with decimal entries on the screen.
465
+ r"""A mobject that displays a matrix with decimal entries on the screen.
468
466
 
469
467
  Examples
470
468
  --------
@@ -544,7 +542,7 @@ class IntegerMatrix(Matrix):
544
542
 
545
543
 
546
544
  class MobjectMatrix(Matrix):
547
- """A mobject that displays a matrix of mobject entries on the screen.
545
+ r"""A mobject that displays a matrix of mobject entries on the screen.
548
546
 
549
547
  Examples
550
548
  --------