Git Product home page Git Product logo

asciigraphs's Introduction

asciigraphs

Python package to parse functions from their ascii graphs. This is a single module package with less then 30 lines of code and no dependencies. Runs on Python >= 3.6

See Also

Python library for parsing ASCII directed graphs

install

pip install git+https://github.com/decatur/asciigraphs.git

Example Single Function

from ..asciigraph import parse_ascii_func
f = parse_ascii_func(glyph='*', graph="""
        3|     *
        2|*   *
        1| * *
        0|--*------------
    """)

print(f)  # {0: 2, 1: 1, 2: 0, 3: 1, 4: 2, 5: 3}

Example Multiple Functions

from ..asciigraph import parse_ascii_funcs
g, h, p = parse_ascii_funcs(glyphs=['*', '+', '#'], graph="""
       g()
       3|     *
       2|*   *
       1| * *
       0|--*------------

     h() p()
       3|  +
       2|++ 
       1|##
       0|--#------------
   """)

print(g)  # {0: 2, 1: 1, 2: 0, 3: 1, 4: 2, 5: 3}
print(h)  # {0: 2, 1: 2, 2: 3}
print(p)  # {0: 2, 1: 2, 2: 3}

Example Custom Index

from ..asciigraph import parse_ascii_func
ts = parse_ascii_func(glyph='*', graph="""
    3|     *
    2|*   *
    1| * *
    0|--*------------
""", index=[str(date(2020, 6, day)) for day in range(12, 18)])

print(ts)  # {'2020-06-12': 2, '2020-06-13': 1, '2020-06-14': 0, '2020-06-15': 1, '2020-06-16': 2, '2020-06-17': 3}

asciigraphs's People

Contributors

decatur avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.