Giter VIP home page Giter VIP logo

algorithmx-python's Introduction

AlgorithmX Python

build PyPI version

AlgorithmX Python is a library for network visualization and algorithm simulation, built on AlgorithmX. It can be used through a HTTP/WebSocket server, or as a widget in Jupyter Notebooks and JupyterLab.

Resources

Installation

Python 3.7.0 or higher is required. Using pip:

python -m pip install algorithmx

Jupyter Widget

In classic Jupyter notebooks, the widget will typically be enabled by default. To enable it manually, run

jupyter nbextension enable --sys-prefix --py algorithmx

with the appropriate flag. To enable in JupyterLab, run

python -m jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build
python -m jupyter lab build

Example Usage

If you wish to use the library through a HTTP/WebSocket server, follow the template below:

import algorithmx

server = algorithmx.http_server(port=5050)
canvas = server.canvas()

def start():
    canvas.nodes([1, 2]).add()
    canvas.edge((1, 2)).add()

canvas.onmessage('start', start)
server.start()

The graphics can be found at http://localhost:5050/.

If you are using Jupyter, try adding the following code to a cell:

from algorithmx import jupyter_canvas

canvas = jupyter_canvas()

canvas.nodes([1, 2]).add()
canvas.edge((1, 2)).add()

canvas

Development

Manual install

Make sure you have Python 3.7 of higher, then run

# build js
cd js
npm run build
cd ..

# install dependencies
python -m pip install -r dev-requirements.txt
python -m pip install --no-deps --editable ".[jupyter,networkx]"

HTTP Server

Docker: Docker-compose up http-server Manually: python examples/basic_http_server.py

Then open localhost:5050 in a browser.

Jupyter notebook

Docker: docker-compose up notebook Manually:

python -m jupyter nbextenion list
python -m jupyter notebook

Then try opening examples/basic_notebook.ipynb.

Jupyter lab

Docker: docker-compose up jupyter-lab Manually:

python -m jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build
python -m jupyter lab build
python -m jupyter labextension list
python -m jupyter lab

Then try opening examples/basic_notebook.ipynb.

Build and test package

Clean any previous builds with rm -rf build dist.

Docker: docker-compose up --build build Manually:

python -m mypy .
python -m pytest tests -vv
python setup.py build sdist bdist_wheel

The bundle can be found in dist/.

Distribute

  • Set up pre-commit hooks: pre-commit install
  • Publish to PyPI: ./scripts/deploy.sh

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.