python tools
- Deep:
/home/wjk/Workspace/PyTools
You can add PyTools to your environment path by adding the following content to .bashrc
:
export PYTHONPATH=/home/wjk/Workspace/PyTools:$PYTHONPATH
For example
from mtools import save_json
from datahub.db import DB
- mtools: general tools
- datahub: specific tools for indoor localization databases
- basictorch: specific tools for BasicTorch
Tools including io, numpy and built-in functions.
Since we import *
in mtools.__init__.py
, you can import any function func
by :
from mtools import func
function | Description |
---|---|
save_json(filename, obj) |
save obj to a json file |
load_json(filename) |
load obj from a json file |
save_h5(filename, obj) |
save obj to a h5 file |
load_h5(filename) |
load obj from h5 file |
csvwrite(filename, data, delimiter=',', fmt='%.4f') |
write data to a csv file |
csvread(filename) |
read data from a csv file |
save_mat(filename, **kwargs) |
save variables to a mat file |
save_json
-
Description: save obj to a json file
-
Parameters:
filename* (str)
: filename
obj (object)
: any object want to save
- Usage:
save_json(filename, obj)
load_json
-
Description: load obj from a json file
-
Parameters:
filename* (str)
: filename
- Usage:
obj = load_json(filename)
save_h5
save obj to a h5 file
load_h5
load obj from h5 file
csvwrite
-
Description: write data to a csv file
-
Parameters:
filename* (str)
: filename
data (numpy.ndarray)
: numpy array want to save
delimiter
: default as ,
fmt
: default as four decimal places
- Usage:
csvwrite(filename, data)
csvwrite(filename, data, delimiter=' ')
csvwrite(filename, data, delimiter=' ', fmt='%.8f')
csvread
-
Description: read data from a csv file
-
Parameters:
filename* (str)
: filename
- Usage:
data = csvread(filename)
save_mat
-
Description: save variables to a mat file
-
Parameters:
filename* (str)
: filename
**kwargs (dict)
: variable length parameters
- Usage:
save_mat(filename, train_data=train_data, test_data=test_data)
Extra tools for numpy.
Extra tools for python built-in functions or classes.