TypeError:运行cython程序时,预期的序列对象的len> = 0或单个整数

时间:2019-06-08 03:21:46

标签: python cython typeerror

我正在为源代码编译的名为gmm-rec的程序运行.sh文件,该程序是一种通过显微图像重建分子的算法。

Shell脚本是:

#!/bin/bash
# Reconstruction script for the 70S ribosome example.

# Initial stage.
gmm-rec.py ribosome_input.mrc -v -o coarse.mrc -s 5000 100 100 -g -r 10000 -d 32 -N 2000 -K 200 -a 2.82 -A 2 -p 8 

gmm-plot-stack.py -i coarse_input.mrc coarse_initial_projections.mrc coarse_final_projections.mrc -r 4 -c 6
gmm-plot-stats.py -i coarse_*_stats.csv -o coarse

# Refinement stage. 
gmm-rec.py ribosome_input.mrc -v -o refine.mrc -s 1000 -K 500 -t coarse_transformations.csv -d 64 -N 10000 -a 2.82 -A 2  

gmm-plot-stack.py -i refine_input.mrc refine_initial_projections.mrc refine_final_projections.mrc -r 4 -c 6
gmm-plot-stats.py -i refine_stats.csv -o refine 

但是我得到了错误:

TypeError: expected sequence object with len >= 0 or a single integer.

根据追溯,该错误与调用的文件isomixture.pyx有关,尤其是该行

values = np.zeros(grid.size, dtype='float')

对于构建高斯混合模型(GMM)的网格是必不可少的。

此处的类在每个网格点返回评估值。它利用网格结构来获得显着的加速,尤其是当高斯分量相对于网格较小时。它使用“ exp_fast”代替“ exp”,后者速度更快,但也略有误差。

    Args:
        grid: Grid object
        std_range: multiple of standard deviation to evaluate.

    Returns:
        GridDataReal object with the mixture evaluated on the grid
        as values.



 cpdef GridDataReal evaluate_grid_sparse(self,
                                        Grid2D grid,
                                        double std_range
    cdef:
        GridDataReal evaluated

    # Initialise for evaluation of mixture on grid:
    values = np.zeros(grid.size, dtype='float')
    evaluated = GridDataReal(grid, values)

    self.evaluate_grid_in_place(grid, std_range, evaluated, 0)

    return evaluated

更新:我感觉可能与Python Imaging Library(PIL)有关,因为当我安装不同版本时,会遇到不同的错误,并且上面的错误消失了。 1.1.5版本出现错误:

AttributeError: 'module' object has no attribute 'fromarray'

相关联
I = Image.fromarray(self.reshaped())

在下面的代码中:

    # Create new (smaller) grid.
    g = Grids.resize_centered(self.grid, new_shape)
    # Resize values.
    I = Image.fromarray(self.reshaped())
    I = I.resize(new_shape, Image.ANTIALIAS)
    gd = GridDataReal(g, np.asarray(I).flatten().astype('double'))

    return gd

0 个答案:

没有答案