Skip to content

Commit 1465eef

Browse files
authored
Release 0.1.7 (#10)
* docs + refactor: Sphinx extensions added + Documentation updated + Docstrings updated. (#8) * docs: added intersphinx mapping + add_module_names config updated * docs: fixed references in Animating Arrays guide * docs: viewcode + napolean + autodoc_typehints sphinx extensions added * refactor: updated docstrings for MVariable * docs: changed func domain to meth in Animating Arrays guide * refactor: updated docstrings for MArrayElement * refactor: fixed Scene.play references in MVariable & MArrayElement docstrings + updated .flake8 to ignore error * refactor: docstrings for typing.Union fixed in MVariable + updated .flake8 to ignore error * refactor: updated docstrings for MArray + minor edit to MArrayElement docstrings * Updated docstrings for all methods of MArray. * Updated __init__ and class docstring of MArrayElement. * Renamed MArray.fetch_arr_label() to MArray.fetch_mob_arr_label(). * Placed play_anim and play_anim_args parameter at the end of MArray.append_elem(). * refactor: updated docstrings for MArrayElementComp & MArrayDirection * docs: created refsub.rst + added substitutions in Animating Arrays guide * Created refsub.rst file that contains references to code elements. * Updated Animating Arrays guide with substitutions from refsub.rst. * refactor: updated docstrings for MArrayPointer * feat: MArraySlidingWindow added + docs updated (#9) * feat: MArraySlidingWindow added * docs: MArraySlidingWindow docs added Example Gallery Animating Arrays Guide Reference Manual * docs: updated changelog for release 0.1.7
1 parent 3f76c0d commit 1465eef

13 files changed

Lines changed: 1474 additions & 744 deletions

File tree

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ max-complexity = 15
99
max-line-length = 88
1010
statistics = True
1111
# Prevents some flake8-rst-docstrings errors
12-
rst-roles = attr,class,func,meth,mod,obj,ref,doc,exc
12+
rst-roles = attr,class,func,meth,mod,obj,ref,doc,exc,py:meth,data
1313
rst-directives = manim, SEEALSO, seealso
1414
docstring-convention=numpy
1515

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.7] - 2023-01-09
9+
10+
### PRS
11+
12+
- [#9](https://github.com/drageelr/manim-data-structures/pull/9)
13+
- `MArraySlidingWindow` added.
14+
15+
- [#8](https://github.com/drageelr/manim-data-structures/pull/8)
16+
- Sphinx extensions added (intersphinx, napolean, viewcode, autodoc_typehints).
17+
- Substitution reference file added `refsub.rst` and utilized in Animating Arrays guide.
18+
- Docstrings of all classes updated.
19+
820
## [0.1.6] - 2022-12-26
921

1022
### PRS

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
manim
22
furo
3+
sphinx-autodoc-typehints

docs/source/conf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,28 @@
2424
"sphinx.ext.duration",
2525
"sphinx.ext.autodoc",
2626
"sphinx.ext.autosummary",
27+
"sphinx.ext.intersphinx",
28+
"sphinx.ext.viewcode",
2729
"manim.utils.docbuild.manim_directive",
30+
"sphinx.ext.napoleon",
31+
"sphinx_autodoc_typehints",
2832
]
2933

3034
templates_path = ["_templates"]
3135
exclude_patterns = []
3236

37+
# displays shorter function names that are documented via autodoc - sphinx.ext.autosummary
38+
add_module_names = False
39+
40+
# displays type hint defaults - sphinx_autodoc_typehints
41+
typehints_defaults = "comma"
42+
43+
# allows external documentation to be referred - sphinx.ext.intersphinx
44+
intersphinx_mapping = {
45+
"python": ("https://docs.python.org/3", None),
46+
"manim": ("https://docs.manim.community/en/stable/", None),
47+
}
48+
3349
# -- Options for HTML output -------------------------------------------------
3450
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3551

docs/source/example.rst

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1+
.. include:: ./refsub.rst
2+
13
Example Gallery
24
===============
35

4-
.. currentmodule:: manim_data_structures.m_array
5-
66
Find Pair Sum In Sorted MArray
77
------------------------------
88

99
The code snippet below uses the famous two pointer technique to find the pair sum ``17`` in the sorted array ``[2, 3, 5, 8, 9, 10, 11]``.
1010

11-
.. manim:: MainScene
11+
.. manim:: PairSumExample
1212
:quality: low
1313

1414
from manim_data_structures import *
1515

16-
class MainScene(Scene):
16+
class PairSumExample(Scene):
1717
def isPairSumAnim(self, arr, n, val):
1818
p_i = MArrayPointer(self, arr, 0, 'i', mob_arrow_args={'color': GREEN}, mob_label_args={'color': GREEN})
1919
p_j = MArrayPointer(self, arr, n - 1, 'j', mob_arrow_args={'color': YELLOW}, mob_label_args={'color': YELLOW})
@@ -27,14 +27,14 @@ The code snippet below uses the famous two pointer technique to find the pair su
2727
pair_sum.update_value(arr.fetch_arr()[p_i.fetch_index()] + arr.fetch_arr()[p_j.fetch_index()])
2828

2929
if (pair_sum.fetch_value() == val):
30-
pair_sum.fetch_mob_square().set(fill_color=GREEN)
30+
self.play(pair_sum.fetch_mob_square().animate.set(fill_color=GREEN))
3131
return True
3232
elif(pair_sum.fetch_value() < val):
3333
p_i.shift_to_elem(p_i.fetch_index() + 1)
3434
else:
3535
p_j.shift_to_elem(p_j.fetch_index() - 1)
3636

37-
pair_sum.fetch_mob_square().set(fill_color=RED)
37+
self.play(pair_sum.fetch_mob_square().aniamte.set(fill_color=RED))
3838
return False
3939

4040
def construct(self):
@@ -43,3 +43,44 @@ The code snippet below uses the famous two pointer technique to find the pair su
4343
self.add(arr)
4444
self.isPairSumAnim(arr, 7, 17)
4545
self.wait(1)
46+
47+
Maxmimum Sum of K Consecutive Integers in MArray
48+
------------------------------------------------
49+
50+
The code snippet below uses the sliding window technique to find the maximum sum of ``k = 4`` consecutive elements in the array ``[1, 4, 2, 10, 2, 3, 1, 0, 20]``
51+
52+
.. manim:: PairSumExample
53+
:quality: low
54+
55+
from manim_data_structures import *
56+
57+
class PairSumExample(Scene):
58+
def maxSumAnim(self, marr: MArray, k):
59+
arr = marr.fetch_arr()
60+
n = len(arr)
61+
62+
window = MArraySlidingWindow(self, marr, 0, k, 'Window')
63+
var_window_sum = MVariable(self, sum(arr[:k]), label='Window Sum')
64+
var_max_sum = MVariable(self, var_window_sum.fetch_value(), label='Max Sum')
65+
var_window_sum.shift(DOWN)
66+
var_max_sum.shift(DOWN * 2.5)
67+
68+
self.play(Create(window))
69+
self.play(Create(var_window_sum), Create(var_max_sum))
70+
71+
for i in range(n - k):
72+
window.shift_to_elem(i + 1)
73+
var_window_sum.update_value(var_window_sum.fetch_value() - arr[i] + arr[i + k])
74+
if var_window_sum.fetch_value() > var_max_sum.fetch_value():
75+
var_max_sum.update_value(var_window_sum.fetch_value())
76+
77+
78+
self.play(var_max_sum.fetch_mob_square().animate.set(fill_color=GREEN))
79+
return var_max_sum.fetch_value()
80+
81+
def construct(self):
82+
arr = MArray(self, [1, 4, 2, 10, 2, 3, 1, 0, 20], label='Array')
83+
arr.shift(UP * 1.5 + LEFT * 4)
84+
self.add(arr)
85+
self.maxSumAnim(arr, 4)
86+
self.wait(1)

0 commit comments

Comments
 (0)