小编kaz*_*r.r的帖子

flax8/pylint在Tox测试环境中失败,引发InvocationError

我一直在学习如何在tox中为我的python项目进行测试.

我有(应该是)一个相当标准的tox初始化文件,如下所示:

[tox]
envlist=py27,flake8
...
[testenv:flake8]
deps=flake8
commands=flake8 library # 'library' is temp. name of project
Run Code Online (Sandbox Code Playgroud)

一切看起来都很正常,所有测试工作,甚至flake8输出都通过(下面的输出).但是,tox引发了一个InvocationError(它在使用pylint进行测试时也是如此)

flake8 recreate: /Users/shostakovich/projects/project_templates/library/.tox/flake8
flake8 installdeps: flake8
flake8 inst: /Users/shostakovich/projects/project_templates/library/.tox/dist/library-0.1.0.zip
flake8 installed: flake8==2.4.1,library==0.1.0,mccabe==0.3,pep8==1.5.7,pyflakes==0.8.1,wheel==0.24.0
library/__main__.py:12:1: F401 'os' imported but unused
library/__main__.py:13:1: F401 're' imported but unused
...
ERROR: InvocationError: '/Users/shostakovich/projects/project_templates/library/.tox/flake8/bin/flake8 library'
Run Code Online (Sandbox Code Playgroud)

我在MaxOSX 10.9.5上运行tox 2.0.2.如果我直接调用flake8或pylint(上面显示了flake8的版本),问题就消失了.

python testing tox flake8

13
推荐指数
1
解决办法
5700
查看次数

Cython:CPP 类似字典的地图性能

我一直在比较使用模仿 python 字典的 c++ 映射与在 cython 中使用普通 python 字典的性能。我在 sklearn ( https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/fast_dict.pyx )中编写了“fast_dict”实现的(简化)变体。与 fast_dict 文档字符串中的注释一致,在 cpp 情况下,地图创建速度要慢得多,但查找也是如此(我希望它快得多)。

我的实现基本上是这样的(主要是从 sklearn 实现中提取的,但经过修改以涉及来自 Int->Int 的映射):

from libcpp.map cimport map as cpp_map
from cython.operator cimport derefernce as deref

cdef class IntDict:

    def __init__(self,dict orig_dict={}):
        """loads from an ordinary dict directly"""
        for key,val in orig_dict.iteritems():
            self.my_map[key] = val

    def __setitem__(self, int key, int value):
        self.my_map[key] = value

    def __getitem__(self, int key):
        cdef cpp_map[ITYPE_t,ITYPE_t].iterator it = self.my_map.find(key)
        if it == self.my_map.end():
            raise KeyError('%d' % key)
        return …
Run Code Online (Sandbox Code Playgroud)

c++ dictionary cython

6
推荐指数
0
解决办法
2815
查看次数

标签 统计

c++ ×1

cython ×1

dictionary ×1

flake8 ×1

python ×1

testing ×1

tox ×1