小编Dev*_*vil的帖子

在Ubuntu服务器上安装h5py

我在Ubuntu服务器上安装h5py.但是它似乎返回了一个h5py.h未找到的错误.当我使用pipsetup.py文件安装它时,它会给出相同的错误消息.我在这里错过了什么?

我有Numpy版本1.8.1,高于1.6或更高版本所需的版本.

完整输出如下:

van@Hulk:~/h5py-2.3.1? sudo python setup.py install
libhdf5.so: cannot open shared object file: No such file or directory
HDF5 autodetection failed; building for 1.8.4+
running install
running bdist_egg
running egg_info
writing h5py.egg-info/PKG-INFO
writing top-level names to h5py.egg-info/top_level.txt
writing dependency_links to h5py.egg-info/dependency_links.txt
reading manifest file 'h5py.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.c' under directory 'win_include'
warning: no files found matching '*.h' under directory 'win_include'
writing manifest file 'h5py.egg-info/SOURCES.txt'
installing library …
Run Code Online (Sandbox Code Playgroud)

python installation installer python-2.7 h5py

46
推荐指数
3
解决办法
4万
查看次数

查找python中一组字符串的最小汉明距离

我有一组n(~1000000)字符串(DNA序列)存储在列表trans中.我必须找到列表中所有序列的最小汉明距离.我实施了一个天真的暴力算法,它运行了一天多,还没有给出解决方案.我的代码是

dmin=len(trans[0])
for i in xrange(len(trans)):
    for j in xrange(i+1,len(trans)):
            dist=hamdist(trans[i][:-1], trans[j][:-1])
            if dist < dmin:
                    dmin = dist
Run Code Online (Sandbox Code Playgroud)

有没有更有效的方法来做到这一点?Hamdist是我写的一个函数,用于查找汉明距离.它是

def hamdist(str1, str2):
    diffs = 0
    if len(str1) != len(str2):
        return max(len(str1),len(str2))
    for ch1, ch2 in zip(str1, str2):
        if ch1 != ch2:
          diffs += 1
    return diffs
Run Code Online (Sandbox Code Playgroud)

python algorithm bigdata hamming-distance

6
推荐指数
1
解决办法
7448
查看次数

查找python中较长字符串中是否存在短字符串的有效方法

我有一个短字符串文件,我已经加载到列表中short(有150万个长度为150的短字符串).我想找到代码中较长字符串(长度约为500万)的短字符串的数量seq.我使用以下明显的实现.但是,这似乎需要很长时间(大约一天)才能运行.

count1=count2=0
for line in short:
    count1+=1
    if line in seq:
            count2+=1
print str(count2) + ' of ' + str(count1) + ' strings are in long string.'
Run Code Online (Sandbox Code Playgroud)

有没有办法可以更有效地做到这一点?

python string performance find

5
推荐指数
1
解决办法
1139
查看次数

通过seaborn stripplot中的数据框列(分类)更改标记样式

我希望将分类变量可视化为seaborn stripplot 中的标记样式,但这似乎并不容易。是否有捷径可寻。例如,我正在尝试运行这段代码

tips = sns.load_dataset("tips")
sns.stripplot(x="day", y="total_bill", hue="time", style="sex", jitter=True, data=tips)
Run Code Online (Sandbox Code Playgroud)

这失败了。另一种方法是使用 relplot,它确实提供了选项,但无法插入,jitter这使得可视化效果不太好。

sns.relplot(x="day", y="total_bill", hue="time", data=tips, style="sex")
Run Code Online (Sandbox Code Playgroud)

提供此的作品

在此输入图像描述

有没有办法使用 stripplot/catplot/swarmplot 来做到这一点?

编辑:这个问题是相关的。然而,那里的解决方案似乎不允许生成尺寸图例(并且相当过时)。

python matplotlib seaborn jupyter jupyter-notebook

3
推荐指数
1
解决办法
3147
查看次数