我想用tox
两个virtualenvs运行我的单元测试,因为我的应用程序必须支持2个不同的Python版本.
我的问题是tox
需要a setup.py
,但我没有,因为我的应用程序不是模块并且有自己的安装程序.现在我不想经历自动化安装过程的麻烦setup.py
,我只想运行我的单元测试而不必写一个setup.py
.
那可能吗?或者我怎么能写一个"空"的setup.py,什么都不做?你能指点我一些关于这个主题的distutils
文档(文档解释了如何写一个有意义的setup.py
,而不是空的)?
我正在为LaTeX编写一个文档类,我希望它是通用的.在这个文档类中,我重新定义了\maketitle
显示自定义标题页面的命令,在这里我想显示一些信息,如标题,作者等,还有一些其他信息.这是我显示标题的方式:
{\LARGE{\bf \@title}}\\
Run Code Online (Sandbox Code Playgroud)
我想创建一个与之类似的新命令,\title
或者\author
我该怎么做?
我有一系列for循环,它们在原始的字符串列表上工作,然后逐渐过滤列表,例如:
import re
# Regex to check that a cap exist in string.
pattern1 = re.compile(r'\d.*?[A-Z].*?[a-z]')
vocab = ['dog', 'lazy', 'the', 'fly'] # Imagine it's a longer list.
def check_no_caps(s):
return None if re.match(pattern1, s) else s
def check_nomorethan_five(s):
return s if len(s) <= 5 else None
def check_in_vocab_plus_x(s,x):
# s and x are both str.
return None if s not in vocab else s+x
slist = ['the', 'dog', 'jumps', 'over', 'the', 'fly']
# filter with check_no_caps
slist = [check_no_caps(s) …
Run Code Online (Sandbox Code Playgroud) 我正在构建一个使用Intel的IPP库的C++应用程序.默认情况下,此库安装在/ opt中,并且要求您设置LD_LIBRARY_PATH
编译和运行软件(如果选择共享库链接,我会这样做).我已经修改了我configure.ac
/ Makefile.am
我在编译时不需要设置该变量,但是我仍然无法在运行时找到共享库; 我怎么做?
我正在使用-Wl, -R/path/to/libdir
标志进行编译g++
更新1:实际上我的二进制程序有一些正确链接的IPP库,但只有一个不是:
$ ldd myprogram
linux-vdso.so.1 => (0x00007fffa93ff000)
libippacem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippacem64t.so.6.0 (0x00007f22c2fa3000)
libippsem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippsem64t.so.6.0 (0x00007f22c2d20000)
libippcoreem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippcoreem64t.so.6.0 (0x00007f22c2c14000)
[...]
libiomp5.so => not found
libiomp5.so => not found
libiomp5.so => not found
Run Code Online (Sandbox Code Playgroud)
当然图书馆在那里:
$ locate libiomp5.so
/opt/intel/ipp/6.0.2.076/em64t/sharedlib/libiomp5.so
Run Code Online (Sandbox Code Playgroud) 我正在使用boost :: asio构建的UDP服务器,我从教程中开始定制我的需求.当我调用socket.receive_from(boost::asio::buffer(buf), remote, 0, error);
它时,用数据包中的数据填充我的缓冲区,但是,如果我的理解是正确的,它会丢弃任何不适合缓冲区的数据.对receive_from的后续调用将接收下一个可用的数据报,因此在我看来,即使没有通知,也会有一些数据丢失.我理解这是错误的方式吗?
我试着一遍又一遍地阅读boost :: asio文档,但我没有设法找到关于我应该以正确的方式做到这一点的线索.我想做的是读取一定数量的数据,以便我可以处理它; 如果读取整个数据报是唯一的方法,我可以管理它,但是我怎么能确保不丢失我收到的数据?我应该使用什么缓冲区大小来确定?有什么方法可以告诉我我的缓冲区太小而且我丢失了信息吗?
我不得不假设我可能会收到大量的数据报.
我使用autoconf检测boost库,在autoconf-archive宏的支持下,它们可以与系统范围的boost库一起使用,但是如果我在我的主目录中手动编译boost,则会失败:
sb@stephane:~/devel/spectra2$ ./configure --with-boost=/home/sb/local/
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... …
Run Code Online (Sandbox Code Playgroud) 我想使用JPA CriteriaBuilder创建一个查询,我想添加一个ORDER BY
子句.这是我的实体:
@Entity
@Table(name = "brands")
public class Brand implements Serializable {
public enum OwnModeType {
OWNER, LICENCED
}
@EmbeddedId
private IdBrand id;
private String code;
//bunch of other properties
}
Run Code Online (Sandbox Code Playgroud)
嵌入式课程是:
@Embeddable
public class IdBrand implements Serializable {
@ManyToOne
private Edition edition;
private String name;
}
Run Code Online (Sandbox Code Playgroud)
我构建查询的方式是这样的:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Brand> q = cb.createQuery(Brand.class).distinct(true);
Root<Brand> root = q.from(Brand.class);
if (f != null) {
f.addCriteria(cb, q, root);
f.addOrder(cb, q, root, sortCol, ascending);
}
return em.createQuery(q).getResultList();
Run Code Online (Sandbox Code Playgroud)
这里有一些函数: …
我想记录一些类,这些类都是从具有一些公共属性的相同基类派生的,我想重复子类中每个属性的文档,以便我可以在一个地方看到类的所有属性.
所以例如我有这个代码:
class Base(object):
"""Base class."""
#: First attribute
a = int
#: Second attribute
b = str
class FirstChild(Base):
"""First Child of Base."""
#: Child attribute
c = float
class SecondChild(Base):
"""Second Child of Base."""
pass
Run Code Online (Sandbox Code Playgroud)
我有这个第一个:
.. automodule:: example
:members:
:show-inheritance:
Run Code Online (Sandbox Code Playgroud)
输出将如下所示:
class class example.Base
Bases: "object"
Base class.
a
First attribute
alias of "int"
b
Second attribute
alias of "str"
class class example.FirstChild
Bases: "example.Base"
First Child of Base.
c
Child attribute
alias of "float"
class class …
Run Code Online (Sandbox Code Playgroud) 我有一个类,对象作为成员,没有默认的构造函数.我想在构造函数中初始化这个成员,但似乎在C++中我不能这样做.这是班级:
#include <boost/asio.hpp>
#include <boost/array.hpp>
using boost::asio::ip::udp;
template<class T>
class udp_sock
{
public:
udp_sock(std::string host, unsigned short port);
private:
boost::asio::io_service _io_service;
udp::socket _sock;
boost::array<T,256> _buf;
};
template<class T>
udp_sock<T>::udp_sock(std::string host = "localhost",
unsigned short port = 50000)
{
udp::resolver res(_io_service);
udp::resolver::query query(udp::v4(), host, "spec");
udp::endpoint ep = *res.resolve(query);
ep.port(port);
_sock(_io_service, ep);
}
Run Code Online (Sandbox Code Playgroud)
编译器基本上告诉我它找不到udp :: socket的默认构造函数,根据我的研究,我理解C++在调用构造函数之前隐式初始化每个成员.有没有办法以我想要的方式去做,或者它是否"面向Java"并且在C++中不可行?
我通过像这样定义我的构造函数解决了这个问题:
template<class T>
udp_sock<T>::udp_sock(std::string host = "localhost",
unsigned short port = 50000) : _sock(_io_service)
{
udp::resolver res(_io_service);
udp::resolver::query query(udp::v4(), host, "spec");
udp::endpoint ep = *res.resolve(query); …
Run Code Online (Sandbox Code Playgroud) 我正在使用这个zurb-foundation下拉按钮 - http://foundation.zurb.com/sites/docs/v/5.5.3/components/dropdown_buttons.html
但是,当用户在下拉按钮本身外部单击或用户单击下拉列表中的项目时,我还需要关闭下拉列表,因此我需要一种方法以编程方式关闭打开的下拉列表事件.
我需要以编程方式关闭打开的下拉列表来进行什么javascript调用?
c++ ×4
boost ×2
python ×2
autoconf ×1
autodoc ×1
autotools ×1
boost-asio ×1
constructor ×1
criteria-api ×1
dictionary ×1
distutils ×1
filter ×1
g++ ×1
intel-ipp ×1
java ×1
javascript ×1
jpa ×1
latex ×1
nested-loops ×1
oop ×1
reduce ×1
sockets ×1
tox ×1
udp ×1
unit-testing ×1