Get the complete structure of a program? - python

I would have a quite simple question, but can't find any suitable automated solution for now.
I have developed an algorithm that performs a lot of stuff (image processing in fact) in Python.
What I want to do now is to optimize it. And for that, I would love to create a graph of my algorithm.
Kind of an UML chart or sequencial chart in fact, in which functions would be displayed with inputs and ouptuts.
My algorithm does not imply complex stuff, and is mainly based on a = f(b) operations (no databases, hardware stuff, server, . . . )
Would you have any hint?
Thanks by advance !

UML generation is provided by pyreverse - it's part of pylint package
It generates UML in dot format - or png, etc.
It creates UML diagram, so you can easily see basic structure of your code
I'm not sure if it satisfy all your needs, but it might be helpful

Take a look at this:
http://blog.prashanthellina.com/2007/11/14/generating-call-graphs-for-understanding-and-refactoring-python-code/

Related

Create a viewer/editor of directed acyclic graph with python

Until now I've been using the streamlit framework for most of plotting and visualizing but recently I've had some new ideas. Long story short, something like Unreal's Blueprint editor is what I need (that's a bit too much, I know). For now I would be content with something least remotely similar to it. As only a few people will be using it so it is not a product just a sketch.
Maybe we can omit some of the details and say that we have a Pipeline.
Meaning it has some Steps, which in turn have Inputs and Outputs.
Then we say that earlier steps do not have access to later outputs.
Now we have a picture. And that picture would be an acyclic graph!
But maybe you see other options. How would you approach such a problem?

Visualizing the relationships of classes and methods in Python

I am reading the source code of a game written in Python, which involves a lot of methods under many classes tangles together. I want to start with a graph which gives an overview of the whole package. Something like Class1.methodA uses Class2.methodA and Class2.methodC; Class2.methodC uses Class2.methodB.... And presented in a graph with nodes and arrows so that I can see the dependencies clearly.
I can certainly do that manually level by level, but that will take a lot of time and might mess up when it gets complex.
I've seen a tool called "snakefood" which visualize dependencies. I tried but failed (does not work for Python3? I am not sure why. And therefore also not sure if it is what I am looking for). Any suggestions?

Any way to reorder variables for binary decision diagrams?

I am working on a teaching tool for binary decision diagrams in which there is also a feature for variable reordering. Can anyone suggest a suitable library which implements variable reordering while building the tree or some kind of algorithm which implements the same ?
It would be best if I could work with a library like pyeda, buDDy or pycudd because I am already familiar with these libraries.
Thanks and comment if you need any kind of clarification..
Have you looked at dd, by Ioannis Filippidis?
I'm the author of pyeda. Implementing ROBDDs in Python was definitely fun, and can probably have some educational value, but it definitely doesn't do any automatic variable reordering, so if that's a requirement I would recommend looking at dd or the other ones on your list.
My group at University of Maribor is producing BDD Scout ( http://biddy.meolic.com/ ), a tool for visualization of BDDs. Currently, ROBDDs with complemented edges and 0-sup-BDDs with complemented edges are supported. Conversions are supported. Reordering (i.e. variable swapping and sifting algorithm) is supported for both of them. BDD Scout work on GNU/Linux an MS Windows (source and binary packages are available). We hope that our tool one day becomes a good teaching tool but we need some feedback to improve it. Besides the robustness the set of the functionalities is the most critical part to improve. If you will find some time to try it do not hesitate to give us any comments and questions.

What kind of algorithm should I look for in order to recognize the blueprint of a building?

I have a project in which I should analyze the layout of a building in order to navigate inside it, and I was thinking about taking the blueprint of the building (or maybe an edited version of the blueprint, which should be modified in some way I am still thinking of), transforming it in some kind of object and then elaborate it.
Basically, I was thinking about doing something similar to OCR but limited (and I guess using limited sounds pretty silly to most of you, but still bear with me) to recognition of, for example, walls and doors. My idea was transforming the whole image into a matrix of points - I guess, a lower resolution version of the source - and then elaborating over the matrix the route from point A to point B.
This is the idea, but I guess that I'm actually looking at a problem way more complex than it looks to me, moreover I don't really know whether this is the best (read: easiest) way to proceed.
In short, my question is:
Is this framework feasible? Are there any libraries for, say, Python, with similar functions? Is the recognition doable by working in someway with a graphic design software (e.g. Photoshop)?

Is there a python library to generate STL file for 3D printing?

I am currently in a project where a lot of 3D printing designs need to be done. They are all parameterized, so I'd like to write a python code to generate those design files (in .STL format) for me. I was wondering that, is there a python package that can do this? Because currently I am all doing those by hand using SolidWorks.
Thanks!
Yes there is... It's called FreeCAD.
The assembly module is already in the devel version (as of 06/15/2014) and will be of production quality really soon for real assemblies!
http://freecadweb.org/
Yes, more than one.
In my humble experience, I tried many Open Source tools for parametric CAD modeling using Python (FreeCAD, Rhino-Grasshopper, Blender, Salome).
All of them are valid options and the best one is represented by your ability to either model or code.
I recently favour SALOME (www.salome-platform.org) because of the straight forward "dump study" option, the continue development and the good API documentation.
Particularly I did some 3d prints using the exportSTL command once I had a solid worthy of printing and it was ok.
Nevertheless, if you intend to work on surfaces rather than solids, I don't think you will find anything worthy Open Source (Rhino has a little price to pay).
There is also a new one ! called pymadcad
It's a library meant to do complete CAD stuff only with python scripts.
At contrary to FreeCAD, Pymadcad is natively dealing with triangular meshes so it makes it very easy to import/export .stl files.
There is a growing amount of surface generation functions (extrusion, revolution, tube, screw, smooth surface, ...). And there is also all the stuff to generate and deal with 3D primtives such as Lines, Arc, ...
Here is a brief look at the features

Categories

Resources