支持analyzere包的python附加程序
analyzere-extras的Python项目详细描述
analyzere python库的一个扩展,它促进了“extras” 包括分析层视图对象的可视化。
安装
pip install analyzere_extras
绘图选项
此绘图实用程序提供了一些控制渲染图像的样式和格式的方法。
- rankdir='xx' 控制图形方向的选项。选项包括:
- “bt”自下而上(默认)
- “tb”自上而下
- “lr”从左到右
- “RL”从右向左
- 压缩=真假
- 控制是否应忽略重复节点(默认值为true)。此选项倾向于生成较小的图形,应更易于阅读。
- 条件=真假
- 指定一个层的术语包含在图形的每个节点中(默认值为true)。
- 警告=真假
通过将节点染成红色来突出显示具有可疑项的节点。当下列任一条件为真时,将生成警告节点:
- participation = 0.0
- invert = true和filters = []
- attachment或aggregate_attachment=无限
- 最大深度=0
<要处理的图形的最大深度。对于嵌套非常深的结构,这可以减小大小。(默认值为0==所有级别)。
- 最大震源=0
- 对于单个节点的图的损失源的最大数目。(默认值为0==所有源)。
- 颜色=[1-12]
- 为节点和边着色时要使用的颜色数。(默认值=1==黑色,最大值=12)。
- 颜色模式=['width''depth']
- 应用颜色时使用的模式。选项包括:[“宽度”,“深度”,默认值:“宽度”。
示例层视图图像:
^{tt6}$ | ^{tt7}$ | |||
---|---|---|---|---|
^{tt8}$ | ^{tt9}$ | ^{tt10}$ | ^{tt11}$ | ^{tt12}$ |
True | True | True | ||
True | True | False | ||
True | False | True | ||
False | False | False |
着色:
^{tt6}$ | ^{tt7}$ | ||
---|---|---|---|
^{tt8}$ | ^{tt16}$ | ^{tt17}$ | ^{tt11}$ |
True | 4 | breadth | |
True | 4 | depth | |
False | 4 | breadth | |
False | 4 | depth |
用法
为了利用分析工具 模块您将需要导入分析器模块。
您需要定义连接信息:
import analyzere analyzere.base_url = '<your server url>' analyzere.username = '<your userid>' analyzere.password = '<your password>'
可视化
要使用可视化工具,需要查询layerview 您要绘制的图形:
from analyzere import LayerView lv = analyzere.LayerView.retrieve('011785b1-203b-696e-424e-7da9b0ec779a')
现在您可以生成图层视图的图形:
from analyzere_extras.visualizations import LayerViewDigraph g = LayerViewDigraph(lv) # defaults: with_terms=True, compact=True, rankdir='TB', warnings=True g = LayerViewDigraph(lv, with_terms=False) # omit Layer terms from nodes g = LayerViewDigraph(lv, compact=False) # graph duplicate nodes g = LayerViewDigraph(lv, rankdir='LR') # render the graph from Left to Right g = LayerViewDigraph(lv, warnings=False) # disable error node highlighting
然后渲染图形:
g.render() # defaults: filename=None, view=True, format=None, rankdir=None g.render(filename='mygraph') # write graph to 'mygraph' g.render(view=True) # attempt to auto display the graph g.render(format='pdf') # change the output format 'pdf' g.render(rankdir='LR') # render the graph from Left to Right
快捷方式:生成给定图层的图形视图ID:
graph = LayerViewDigraph.from_id('011785b1-203b-696e-424e-7da9b0ec779a')
ELT组合
要使用elt组合器工具,您需要定义 uuid表示要组合的elt资源:
uuid_list = ['26a8f73b-0fbb-46c7-8dcf-f4de1e222994', 'cd67ba03-302b-45e5-9341-a4267875c1f8']
您需要指出这些ELT对应的目录:
catalog_uuid = '61378251-ce85-4b6e-a63c-f5d67c4e4877'
然后将ELT组合成一个ELT:
from analyzere_extras.combine_elts import ELTCombiner elt_combiner = ELTCombiner() combined_elt = elt_combiner.combine_elts_from_resources( uuid_list, catalog_uuid, uuid_type='all', description='My Combined ELT' )
uuid_type指定uuid_list中的资源类型。有效 uuid_type的值为:
- ^{tt22}$
- ^{tt23}$
- ^{tt24}$
- ^{tt25}$
- ^{tt26}$
- ^{tt27}$
如果设置了uuid_type='all',则uuid_list中的资源可以是混合资源 包括公文包、PortfolioView、Layers、LayerView和Lossets。违约 uuid_type的值是'all'。
description定义上载的组合elt的描述。如果没有 set,默认值为'analyzere-python-extras: Combined ELT'。
测试
我们目前承诺与Python2.7和Python3.4到3.7兼容。 为了对我们使用的每个环境运行测试 tox和py.test。你会的 需要为我们测试的每个python版本安装一个解释器。 您可以通过系统的包管理器或 on the Python site。
首先,安装tox:
pip install tox
然后,运行完整的测试套件:
tox
要运行特定模块、测试用例或单个测试的测试,可以通过 py.test到tox的参数,使用--。例如:
tox -- tests/test_base_resources.py::TestReferences::test_known_resource
有关详细信息,请参见tox --help和py.test --help。