Recursion tree
Transforms recursive functions into graphical form.
Installation:
pip install RecursionTree
Usage:
import random
from RecursionTree import recursion_tree
scientific_style = {
'draw_boundary': False,
'color_background': 'white',
'color_num_background': 'white',
'color_node_body': 'white',
'color_node_stroke': 'black',
'color_text': 'black',
'color_connection': 'black',
'node_stroke_bezier': False
}
@recursion_tree(scientific_style)
def fibo(x: int) -> int:
return 1 if x in [1, 2] else fibo(x=x - 1) + fibo(x=x - 2)
# No parameters mean default settings
@recursion_tree
def random_tree(x: int) -> str:
if x == 0:
return 'Dead end'
for _ in range(random.randint(1, x)):
random_tree(x=x - 1)
if __name__ == '__main__':
# Run out target function and save results
fibo(x=5)
random_tree(x=4)
Just add the 'recursion_tree' decorator to any recursive function. The result will be automatically saved as an SVG file. Additional settings might be achieved via settings.py or by passing a dictionary to the decorator.
Default style:
Scientific style:
Default style with boundaries:
Metadata
Release files for RecursionTree 2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| RecursionTree-2.0.tar.gz | 6.8 kB | Without provenance | Details for RecursionTree-2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| RecursionTree-2.0-py3-none-any.whl | Python 3 | none | any | Details for RecursionTree-2.0-py3-none-any.whl |
Total release size: 36.0 kB
Release files / RecursionTree-2.0.tar.gz
| Download URL | RecursionTree-2.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3637dcf25ccd5977aa7868833f5ec8ebda5dd0546d5d48f77e104ad7eb73d63a
|
|
BLAKE2b-256 checksum How to use checksums |
8588e2ce66e0e7568771681c9fb21059c9aeb925ce0de96cd562f40d65bedfd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1rc1
|
Release files / RecursionTree-2.0-py3-none-any.whl
| Download URL | RecursionTree-2.0-py3-none-any.whl |
|---|---|
| Size | 29.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70b766557cde68de48669a2792b27b0595fa5133aa9d25585aa0096e9def72fb
|
|
BLAKE2b-256 checksum How to use checksums |
2e75340dcebe075c9a66757fd62ee76ff7308b18a6d52b75ada6b638168e0f27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1rc1
|
Security for RecursionTree 2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.