boxx
boxx copied to clipboard
Tool-box for efficient build and debug in Python. Especially for Scientific Computing and Computer Vision.
Box-X
Introduce | Install | Tutorial | Examples | Acknowledgments
1. Introduce
Box-X
is a Tool-box for Efficient Build and Debug in Python.
Especially for Scientific Computing and Computer Vision.
So, all Tools are divided into 2 parts by wether the tool is general used:
-
General Python Tool: Tools could be used anywhere in Python
-
Scientific Computing and Computer Vision Tool: Those tools are useful in Scientific Computing and Computer Vision field
P.S. boxx
supports both Python 2/3
on Linux | macOS | Windows
with CPython | IPython | Spyder | Notebook
environment.
2. Install
pip install boxx
3. Tutorial
Box-X
's Tutorial is a Jupyter Notebook file
There are 3 methods to run or view this Notebook file
Method 1: Executable Interactive Online Notebook
We use Binder to run Tutorial Notebook in an executable interactive online jupyer environment.
That's mean you can run code in notebook rightnow in your browser without download or install anything.
Method 2: Download and Run at Local
git clone https://github.com/DIYer22/boxx
cd boxx/
python setup.py install
jupyter notebook
Then open ./tutorial_for_boxx.ipynb
in notebook.
Method 3: Static Noetbook
Just view the Tutorial Notebook.
4. Examples
Examples are divided into 2 parts too.
General Python Tool on left, Scientific Computing and Computer Vision Tool on right.
💡 Note:
- Click the image will see more clearer image, and if image is GIF, GIF will be replayed
- The following content is layout of desktop browser, if you are viewing through a mobile browser, it is recommended to visit => Static Tutorial
General Python Tool▶
|
Scientific Computing and Computer VisionUseful tools in Scientific Computing and Computer Vision field. All tools support array-like types, include 💡 Note: If you are using ▶
|
▶
|
How many vars \ Operation | transport | print & transport | |
---|---|---|---|
Single variable | p/x |
g.name/x |
gg.name/x |
Multi variables | with p: |
with g: |
with gg: |
All locals() |
p() |
g() |
gg() |
All locals() _2 |
import boxx.p |
import boxx.g |
import boxx.gg |
💡 Note:
- transport mean "transport variable to Python interactive console"
-
All
locals()
mean operation will act on all variables in the function or module -
All
locals()
_2 : whenboxx
are not imported,import boxx.{operation}
is a convenient way to execution operation
▶ what
to know "What's this?"
💡 Note: what(x)
will show "what is x
?" by pretty print it's Self, Document, Father Classes, Inner Struct and Attributes. It is a supplement of help(x)
.
▶ timeit
is convenient timing tool
💡 Note: timeit
will timing code block under "with statement" and print spend time in blue color.
▶ mapmp
is Multi Process version of map
mapmp
is the meaning of "MAP for Multi Process", has the same usage as map
but faster.
💡 Note:
-
pool parameter in
mapmp
mean the number of Process, the default is the number of CPUs in the system. - In multi process programs, display processing progress is troublesome. printfreq parameter in
mapmp
can handle this problem. - Like
map
,mapmp
support muliti args to as input to function, likemapmp(add, list_1, list_2)
. -
- It's better to run multi process under
__name__ == '__main__'
environment.
- It's better to run multi process under
- If you speed up the
numpy
program, note that in the MKL version ofnumpy
, multiple processes will be slower. You can runboxx.testNumpyMultiprocessing()
to test how friendly the current environment is to a multi-processnumpy
.
▶ heatmap
to show the time heat map of your code
💡 Note: heatmap
also support python code string.
▶ performance
could statistic function calls and visualize code performance
💡 Note: performance
also support python code string.
5. Acknowledgments
- Thanks to Xiaodong Xu, Guodong Wu, Haoqiang Fan, Pengfei Xiong for their suggestions
- I develop
boxx
in Spyder IDE, Spyder is a awesome Scientific Python Development Environment with Powerful Qt-IPython -
performance
is supported by SnakeViz -
heatmap
is supported by csurfer/pyheat