使用具有大量维度的numpy.array

时间:2016-02-04 04:28:28

标签: python numpy

如果您尝试在numpy中创建具有大量维度的数组,则会引发异常:

In [1]: import numpy as np

In [2]: a = np.zeros((1,) * 33)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-32dc30f6e439> in <module>()
----> 1 a = np.zeros((1,) * 33)

ValueError: sequence too large; must be smaller than 32

这有什么简单的解决方法吗?

numpy不允许创建此类数组的原因是什么?

1 个答案:

答案 0 :(得分:6)

来自NumPy source code

.directive('priceMonthly', function() {
return {
    restrict: 'A',
    scope:{
      priceMonthly:"=",
      period:"="
    },
    link: function(scope) {
       scope.$watch('period',function(newval){
        if(newval=='monthly')
          scope.priceMonthly = scope.priceMonthly*12;
        if(newval=='yearly')
          scope.priceMonthly = scope.priceMonthly/12;
       })
    }
};});

您可以更改这些定义并从源代码构建符合您需求的不兼容版本。