我有一个包有一个模块,可以帮助用户使用matplotlib生成特定的图.当我在Travis内部的单元测试中调用这些函数时,出现以下错误:
RuntimeError: Invalid DISPLAY variable
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
生成绘图后,我的函数通常会调用pyplot.show()
,这会打开一个需要关闭的窗口.当我在Travis内部的单元测试中调用这些函数时,它们会永远挂起来.
如何测试使用Travis CI生成这些图?
我在我的 PostgreSQL 数据库中创建了一个 Hibernate 使用的模式,创建表,持久化实体等等。在我将 Ubuntu 14.04 更新到 16.04 后,我再也看不到这些表格了。不过,操作模式及其表中数据的应用程序仍然可以执行此操作。
这是我使用登录后的一些命令的输出sudo -u postgres psql
:
postgres=# \dt
No relations found.
postgres=# \dn
List of schemas
Name | Owner
--------+----------
jcat | postgres
public | postgres
(2 rows)
postgres=# \dn+
List of schemas
Name | Owner | Access privileges | Description
--------+----------+----------------------+------------------------
jcat | postgres | postgres=UC/postgres+|
| | =UC/postgres |
public | postgres | postgres=UC/postgres+| standard public schema
| | =UC/postgres |
(2 rows)
Run Code Online (Sandbox Code Playgroud)
我从我发现的几个问题中尝试了以下方法:
GRANT ALL PRIVILEGES ON …
Run Code Online (Sandbox Code Playgroud) 例如,我想获取 tensor 中值为 0 和 2 的元素的索引a
。这些值(0 和 2)存储在 tensor 中b
。我已经设计了一种 pythonic 方法来这样做(如下所示),但我认为列表推导式没有被优化为在 GPU 上运行,或者也许有一种我不知道的更多 PyTorchy 方法来做到这一点。
import torch
a = torch.tensor([0, 1, 0, 1, 1, 0, 2])
b = torch.tensor([0, 2])
torch.tensor([x in b for x in a]).nonzero()
>>>> tensor([[0],
[2],
[5],
[6]])
Run Code Online (Sandbox Code Playgroud)
任何其他建议或者这是一种可以接受的方式?
我一直在我的 PrimeFaces SelectOneMenu 对象中使用转换器。如果我只告诉转换器指的是哪个类,它们就可以正常工作:
@FacesConverter(forClass = DescriptorVO.class)
public class DescriptorVOConverter implements Converter { ... }
Run Code Online (Sandbox Code Playgroud)
这样,我不必明确告诉 JSF 组件在用 class 对象填充时应该使用哪个转换器DescriptorVO
。
但是,我制作了一个使用 a 的页面,p:SelectManyCheckbox
我终其一生都不知道为什么它没有调用我的转换器。然后我给它起了个名字,像这样:
@FacesConverter(forClass = RoleVO.class, value = "roleVOConverter")
public class RoleVOConverter implements Converter { ... }
Run Code Online (Sandbox Code Playgroud)
并将其作为组件的属性之一传递
<p:selectManyCheckbox id="cbx_roles" required="true" converter="roleVOConverter"
requiredMessage="At least one role must be selected."
value="#{userView.selectedRoles}" layout="responsive">
<f:selectItems value="#{userView.roles}" var="role"
itemLabel="#{role.title}" itemValue="#{role}" />
</p:selectManyCheckbox>
Run Code Online (Sandbox Code Playgroud)
和VOI拉,它开始正确地调用该转换器。这向我提出了一个问题,即我应该何时命名我的转换器(通过value
属性)以及何时告诉他们转换器应该与哪个类一起使用(通过forClass
属性)就足够了。在使用 PrimeFaces 时,我从不需要为任何转换器命名,仅为这个特定SelectManyCheckbox
组件命名。不同的组件是否对转换器有不同的要求,还是我只是弄错了转换器的概念?
我试图在Sphinx文档中引用一个表格.我为表命名,然后尝试使用numref
,但它错误地显示了表的标签("modules_classes")而不是它的编号.
.. _modules_classes:
.. table:: Modules and their corresponding abstract classes
[table content]
Modules and their corresponding abstract classes are presented on table :numref:`modules_classes`.
Run Code Online (Sandbox Code Playgroud)
我也试过这样做,因为我在网上找到了一个例子,但结果是一样的:
.. table:: Modules and their corresponding abstract classes
:name: modules_classes
Run Code Online (Sandbox Code Playgroud)
我看到它的方式,我不需要导入numfig
包,因为它默认包含在Sphinx中.使用该命令:ref:
显示表的标题,所以我理解引用是正确的.有人能指出我所做的事情有什么不对吗?
python ×3
jsf ×1
jsf-2 ×1
matplotlib ×1
plot ×1
postgresql ×1
primefaces ×1
pytorch ×1
tensor ×1
travis-ci ×1