小而高级的工具,可以填补当前python工具集中的空白。
tinytools的Python项目详细描述
简介
tinytools是一组小的、高级的工具,它们填补了python中的空白 工具组。这些工具被分成一组模块
- bunch:包含一个OrderedBunch对象类,它与 bunchify/unbunchify方法,类似于其他bunch实现,但是 构建了一个ordereddict,其中ipython表完全重载到 数据存储器。
- files:具有可配置的高级筛选和搜索功能 搜索深度、区分大小写和搜索类型。
- cmd_list:精简子进程包装以简化命令行 电话。
- pvl:读写函数 PVL files。
- class_csv:在csv文件中移动列的函数-一个常见的需要 用于在机器学习工具之间移动类属性的csv文件。
- np_img:翻转图像的numpy操作-即转换 numpy图像数组从(4200200)到(200200,4)。
- py_styles:显示python风格的建议。
安装
pipinstalltinytools
导入
importtinytools
或者使用更方便的别名:
importtinytoolsastt
快速启动
importtinytoolsastt## Search functionfound=tt.files.search('/path/to/search',['*.til','proj1*.til'],depth=5,case_sensitive=False)## OrderedBunchfromcollectionsimportOrderedDict# Create an OrderedBunch from and return it to an OrderedDictod=OrderedDict({'a':1,'b':2,'c':{'aa':1.23,'bb':'string'}})ob=tt.bunch.ordered_bunchify(od)ob.a# Explore the OrderdBunch with tab completeob['a']# Equivalent to aboveob.c.bb# orderd_bunchify is recursive on nested Dict objectsob['c']['bb']# Equivalent to aboveod2=tt.bunch.ordered_unbunchify(ob)## Interacting with PVL files# Read full PVL fileimd=tt.pvl.read_from_pvl('/path/to/image.IMD')type(imd)# returns collections.OrderedDictimdob=tt.bunch.ordered_bunchify(img)# Create an ordered bunch to ease# interactive explorationimdob.IMAGE_1.satID# Tab complete through the IMD files# Read an item from a PVL filett.pvl.read_from_pvl('/path/to/image.IMD','satId')# return same as abovett.pvl.read_from_pvl('/path/to/image.IMD','ULLon')# return a list of all# items matching key