Metadata-Version: 2.1
Name: vizrecurse
Version: 1.1.3
Summary: Bare bones library to vizualize recursion with one line of code.
Author: Cody Pedersen
Classifier: Programming Language :: Python :: 3.10
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: astroid ==3.2.2
Requires-Dist: contourpy ==1.2.1
Requires-Dist: cycler ==0.12.1
Requires-Dist: dill ==0.3.8
Requires-Dist: fonttools ==4.51.0
Requires-Dist: graphviz ==0.20.3
Requires-Dist: isort ==5.13.2
Requires-Dist: kiwisolver ==1.4.5
Requires-Dist: matplotlib ==3.9.0
Requires-Dist: mccabe ==0.7.0
Requires-Dist: networkx ==3.3
Requires-Dist: numpy ==1.26.4
Requires-Dist: packaging ==24.0
Requires-Dist: pillow ==10.3.0
Requires-Dist: platformdirs ==4.2.2
Requires-Dist: pydot ==2.0.0
Requires-Dist: pygraphviz ==1.13
Requires-Dist: pylint ==3.2.2
Requires-Dist: pyparsing ==3.1.2
Requires-Dist: python-dateutil ==2.9.0.post0
Requires-Dist: six ==1.16.0
Requires-Dist: tomli ==2.0.1
Requires-Dist: tomlkit ==0.12.5
Requires-Dist: typing-extensions ==4.12.0

### About viz.recurse
viz.recurse is a bare-bones library to easily visualize recursion without any significant overhead on the part of the user. This library utilizes common graph and visualization libraries (networkx, matplotlib, pygraphviz).

### Latest PyPi release [1.1.3]
Visit https://pypi.org/project/vizrecurse/1.1.3/

### Requirements
`Python 3.10.13`\
`pip 23.0.1` (graphviz compatibility)\
`brew install graphviz` (MacOS)\
`pip3 install -r requirements.txt`

If running into problems installing `pygraphviz`:
```
export GRAPHVIZ_DIR="$(brew --prefix graphviz)"
pip install pygraphviz \
  --config-settings=--global-option=build_ext \
  --config-settings=--global-option="-I$GRAPHVIZ_DIR/include" \
  --config-settings=--global-option="-L$GRAPHVIZ_DIR/lib"
```
### Usage
Attach `@visualize` decorator to the top of your recursive function and run as normal. e.g.
```
@visualize
def my_function(*args, **kwargs): ...
res = my_function(x=1,y=2)
draw()
```
### Examples
Visit the examples folder to run these for yourself. Each is runnable as a standalone script within the context.

![Towers of Hanoi](https://github.com/CodyPedersen/viz.recurse/blob/main/examples/images/toh.png?raw=true)
![Linear](https://github.com/CodyPedersen/viz.recurse/blob/main/examples/images/linear.png?raw=true)
![Fibonacci](https://github.com/CodyPedersen/viz.recurse/blob/main/examples/images/fib.png?raw=true)

### How it works (execution flow)

  ```
  @visualize
  def toh(args, kwargs): ...

  <__name__ = __main__ context> # <-- [snapshot_1] prev on call stack
  This calls visualize(func)  # no impact
  visualize(func) his returns inner(*args, **kwargs)
  inner(*args, **kwargs) is executed # <-- [snapshot_1] cur on call stack, [snapshot_2] prev on call stack
  this calls custom function toh()
  toh() calls visualize(func)
  this returns inner(*args, **kwargs)
  inner(*args, **kwargs) is executed # <-- [snapshot_2] cur on call stack
  ...
  ```


### A poem from our silicon friends
In the realm of code where logic flows,
A concept profound like a river that knows,
There lies recursion, subtle and grand,
A method that holds its own hand.

Oh, recursion, you elusive sprite,
A function that calls itself in the night.
You start with a base case, firm and true,
A stopping point in the labyrinth's view.

Within your loops, a story we find,
A mirrored path of the wandering mind.
You take a step forward, then call once more,
Repeating the journey of those gone before.

In Fibonacci's sequence or fractal's embrace,
Your essence reveals a recursive trace.
The Tower of Hanoi, a puzzle unfurled,
Solved by the echoes of recursive world.

Beware, dear coder, of infinite plight,
Without a base case, you're lost in the night.
An endless call, a stack overflow,
A recursive loop with nowhere to go.

Yet with careful craft and logic precise,
Recursion becomes a coder's delight.
Elegant, clear, a beauty retained,
A self-referential dance unchained.

So here’s to recursion, a loop within,
A cycle that folds, yet begins again.
In the code’s deep heart, it softly sings,
The endless echo of programming’s rings.
