支持analyzere包的python附加程序

analyzere-extras的Python项目详细描述


analyzere python库的一个扩展,它促进了“extras” 包括分析层视图对象的可视化。

安装

pip install analyzere_extras

绘图选项

此绘图实用程序提供了一些控制渲染图像的样式和格式的方法。

rankdir='xx'
控制图形方向的选项。选项包括:

  • “bt”自下而上(默认)
  • “tb”自上而下
  • “lr”从左到右
  • “RL”从右向左
压缩=真假
控制是否应忽略重复节点(默认值为true)。此选项倾向于生成较小的图形,应更易于阅读。
条件=真假
指定一个层的术语包含在图形的每个节点中(默认值为true)。
警告=真假

通过将节点染成红色来突出显示具有可疑项的节点。当下列任一条件为真时,将生成警告节点:

  • participation = 0.0
  • invert = truefilters = []
  • attachmentaggregate_attachment=无限
最大深度=0 <要处理的图形的最大深度。对于嵌套非常深的结构,这可以减小大小。(默认值为0==所有级别)。
最大震源=0
对于单个节点的图的损失源的最大数目。(默认值为0==所有源)。
颜色=[1-12]
为节点和边着色时要使用的颜色数。(默认值=1==黑色,最大值=12)。
颜色模式=['width''depth']
应用颜色时使用的模式。选项包括:[“宽度”,“深度”,默认值:“宽度”。

示例层视图图像:

^{tt6}$^{tt7}$
^{tt8}$^{tt9}$^{tt10}$^{tt11}$^{tt12}$
TrueTrueTrueBT_compact_with-terms_warnings-enabledLR_compact_with-terms_warnings-enabled
TrueTrueFalseBT_compact_with-terms_warnings-disabledLR_compact_with-terms_warnings-disabled
TrueFalseTrueBT_compact_without-terms_warnings-enabledLR_compact_without-terms_warnings-enabled
FalseFalseFalseBT_not-compact_without-terms_warnings-disabledLR_not-compact_without-terms_warnings-disabled

着色:

^{tt6}$^{tt7}$
^{tt8}$^{tt16}$^{tt17}$^{tt11}$
True4breadthBT_compact_with-terms_warnings-disabled_4-colors-by-breadth
True4depthBT_compact_with-terms_warnings-disabled_4-colors-by-depth
False4breadthBT_not-compact_with-terms_warnings-disabled_4-colors-by-breadth
False4depthBT_not-compact_with-terms_warnings-disabled_4-colors-by-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兼容。 为了对我们使用的每个环境运行测试 toxpy.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 --helppy.test --help

发布

  1. 安装twinewheel

    pip install twine wheel
    
  2. 增量版本号BER输入setup.py根据 PEP 440

  3. 将更改提交到setup.py,并使用版本为其创建标记 号码。例如:

    git tag 0.1.0
    git push origin 0.1.0
    
  4. 包源和轮分布:

    python setup.py sdist bdist_wheel
    
  5. 用绳线上传到pypi:

    twine upload dist/*
    

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java ScheduleExpression:调度器只在第一个小时工作,为什么?   从Java代码转换时出现Kotlin错误   安卓上条件语句中的java布尔值?   java Wildfly:服务器重新启动后授权失败   java如何从hibernate自动ddl中排除模式   元音的java正则表达式负前瞻   线程中的java异常。我不能执行这个程序   java避免在线程处于特定块中时对静态对象进行全局修改   java布尔方法的行为不符合预期,当预期为true时返回false   java如何删除具有相同对象名的JavaFx标签   安卓W/System。犯错误﹕ JAVA木卫一。FileNotFoundException:访问存储在资产文件夹中的数据库时   gradle中的java条件依赖   Java中的资源、URI、URL、路径和文件有什么区别?   java电子学习平台技术、设计和体系结构