Code Monkey home page Code Monkey logo

bdp's Introduction

Welcome to BDP

BDP (Block Diagrams in Python) aims to become a Python fronted for TikZ when it comes to drawing block diagrams in order to facilitate the process. BDP wraps the TikZ statements into the Python objects so that users can describe diagrams in pure Python. However, inserting raw TikZ in BDP is also possible. Figure below shows an BDP example image which represents the BDP compilation process.

https://raw.githubusercontent.com/bogdanvuk/bdp/master/doc/source/images/compile_process.png

Figure can be rendered with the compile_process.py BDP diagram. It can be rendered into the PNG with BDP via command line:

# bdp compile_process.py -p

For a complete list of command line options please take a look at command_line chapter of the documentation.

Why BDP?

BDP brings following benefits:

  • Diagram description in Python which should render it more readable
  • Step-by-step debugging of the diagram description
  • Use the tools and design environments available for Python development (debugging, code completion, refactoring, documentation utilities...)
  • Use vast Python library of packages

BDP features

BDP package comprises:

  • Python classes that wrap the Tikz statements
  • Class for rendering PDF and PNG images from the Python description
  • Shell entry point for rendering BDP images from command line
  • Sphinx extensions for embedding BDP images into the Sphinx documents

Image below is a more complex example, which shows how power of Python programming can be used to generate diagrams with BDP. Image shows an UML-like diagram of few major BDP templates.

https://raw.githubusercontent.com/bogdanvuk/bdp/master/doc/source/images/uml.png

Figure can be rendered with the uml.py BDP diagram.

Where to start?

Installation

BDP package currently supports only Python 3. Following are alternative ways to install BDP.

Install BDP using pip:

pip3 install bdp

Install BDP using easy_install:

easy_install3 bdp

Install BDP from source:

python3 setup.py install

BDP requires TeX Live, which could be installed on a Debian or a Debian-derived systems, with:

# sudo apt-get install texlive

For converting PDF to PNG, pdftoppm, pnmcrop and pnmtopng are needed, which could be installed on a Debian or a Debian-derived systems, with:

# sudo apt-get install poppler-utils
# sudo apt-get install netpbm

Read the documentation

Read the BDP documentation

Checkout the examples

BDP images used in documentation are located in the images repository documentation folder.

Get involved

Pull your copy from github repository

bdp's People

Contributors

bogdanvuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bdp's Issues

Error while running compile_process.py

I am trying to run the compile_process.py file provided as an example but am getting this error

  File "/usr/local/bin/bdp", line 8, in <module>
    sys.exit(main())
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/render.py", line 212, in main
    render(opts.input, opts.output, None, options)
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/render.py", line 172, in render
    fig = render_tikz(fin)
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/render.py", line 43, in render_tikz
    bdp_mod = loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 962, in load_module
  File "<frozen importlib._bootstrap_external>", line 787, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "diag.py", line 7, in <module>
    fig << block(r"Python \\ Description")
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/figure.py", line 114, in __lshift__
    self.add(val)
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/group.py", line 50, in add
    self.__setitem__(key, obj)
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/figure.py", line 123, in __setitem__
    self._tikz += val._render_tikz(self)
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/node.py", line 681, in _render_tikz
    xallign_self = self.nx(0.0)
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/node.py", line 204, in coord
    return func(self, pos, grid)
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/node.py", line 376, in nx
    return self.n(pos, 0, grid)[0]
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/node.py", line 471, in n
    pos = super().n(p1, p2, grid)
  File "/home/waleeds1/.local/lib/python3.8/site-packages/bdp/node.py", line 163, in coord
    pos[i] *= self.size[i]
TypeError: unsupported operand type(s) for *=: 'float' and 'NoneType'```

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.