Skip to content

Commit

Permalink
Release 0.1.7 (#10)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
drageelr authored Jan 8, 2023
1 parent 3f76c0d commit 1465eef
Show file tree
Hide file tree
Showing 13 changed files with 1,474 additions and 744 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ max-complexity = 15
max-line-length = 88
statistics = True
# Prevents some flake8-rst-docstrings errors
rst-roles = attr,class,func,meth,mod,obj,ref,doc,exc
rst-roles = attr,class,func,meth,mod,obj,ref,doc,exc,py:meth,data
rst-directives = manim, SEEALSO, seealso
docstring-convention=numpy

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

## [0.1.7] - 2023-01-09

### PRS

- [#9](https://github.com/drageelr/manim-data-structures/pull/9)
- `MArraySlidingWindow` added.

- [#8](https://github.com/drageelr/manim-data-structures/pull/8)
- Sphinx extensions added (intersphinx, napolean, viewcode, autodoc_typehints).
- Substitution reference file added `refsub.rst` and utilized in Animating Arrays guide.
- Docstrings of all classes updated.

## [0.1.6] - 2022-12-26

### PRS
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
manim
furo
sphinx-autodoc-typehints
16 changes: 16 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,28 @@
"sphinx.ext.duration",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"manim.utils.docbuild.manim_directive",
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
]

templates_path = ["_templates"]
exclude_patterns = []

# displays shorter function names that are documented via autodoc - sphinx.ext.autosummary
add_module_names = False

# displays type hint defaults - sphinx_autodoc_typehints
typehints_defaults = "comma"

# allows external documentation to be referred - sphinx.ext.intersphinx
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"manim": ("https://docs.manim.community/en/stable/", None),
}

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

Expand Down
53 changes: 47 additions & 6 deletions docs/source/example.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
.. include:: ./refsub.rst

Example Gallery
===============

.. currentmodule:: manim_data_structures.m_array

Find Pair Sum In Sorted MArray
------------------------------

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]``.

.. manim:: MainScene
.. manim:: PairSumExample
:quality: low

from manim_data_structures import *

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

if (pair_sum.fetch_value() == val):
pair_sum.fetch_mob_square().set(fill_color=GREEN)
self.play(pair_sum.fetch_mob_square().animate.set(fill_color=GREEN))
return True
elif(pair_sum.fetch_value() < val):
p_i.shift_to_elem(p_i.fetch_index() + 1)
else:
p_j.shift_to_elem(p_j.fetch_index() - 1)

pair_sum.fetch_mob_square().set(fill_color=RED)
self.play(pair_sum.fetch_mob_square().aniamte.set(fill_color=RED))
return False

def construct(self):
Expand All @@ -43,3 +43,44 @@ The code snippet below uses the famous two pointer technique to find the pair su
self.add(arr)
self.isPairSumAnim(arr, 7, 17)
self.wait(1)

Maxmimum Sum of K Consecutive Integers in MArray
------------------------------------------------

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]``

.. manim:: PairSumExample
:quality: low

from manim_data_structures import *

class PairSumExample(Scene):
def maxSumAnim(self, marr: MArray, k):
arr = marr.fetch_arr()
n = len(arr)

window = MArraySlidingWindow(self, marr, 0, k, 'Window')
var_window_sum = MVariable(self, sum(arr[:k]), label='Window Sum')
var_max_sum = MVariable(self, var_window_sum.fetch_value(), label='Max Sum')
var_window_sum.shift(DOWN)
var_max_sum.shift(DOWN * 2.5)

self.play(Create(window))
self.play(Create(var_window_sum), Create(var_max_sum))

for i in range(n - k):
window.shift_to_elem(i + 1)
var_window_sum.update_value(var_window_sum.fetch_value() - arr[i] + arr[i + k])
if var_window_sum.fetch_value() > var_max_sum.fetch_value():
var_max_sum.update_value(var_window_sum.fetch_value())


self.play(var_max_sum.fetch_mob_square().animate.set(fill_color=GREEN))
return var_max_sum.fetch_value()

def construct(self):
arr = MArray(self, [1, 4, 2, 10, 2, 3, 1, 0, 20], label='Array')
arr.shift(UP * 1.5 + LEFT * 4)
self.add(arr)
self.maxSumAnim(arr, 4)
self.wait(1)
Loading

0 comments on commit 1465eef

Please sign in to comment.