[Numpy-discussion] error fromnumeric: 254 (repeat) return repeat(repeats, axis)

Warren Weckesser warren.weckesser@enthought....
Sat Feb 6 10:04:16 CST 2010


Tom,

'mask' has 285 elements and 'delta' has 284 elements.  If these are to 
be used as arguments of numpy.repeat(), they must be the same length.

Warren

Thomas Evangelidis wrote:
>
> Dear programmers,
>
>
> I'm not familiar with numpy therefore I need a little help to debug 
> code which was not written by me.
>
> The lines which generate the error are the following:
>
>             index = N.concatenate( (index, [len_i]) )
>             delta = index[1:] - index[:-1]
>             return N.repeat( mask, delta.astype( N.int32 ) )
>
>
> and this is the error message I get:
>
>     PDBModel: 1619 (extendMask) return N.repeat( mask, delta.astype(
>     N.int32 ) )
>     functions: 19 (repeat) return np.repeat(a, repeats, axis)
>     fromnumeric: 254 (repeat) return repeat(repeats, axis)
>
>
>
> below I provide you with the values of each variables in these 3 lines 
> of code:
>
>
>      index =  [   0    9   20   29   37   44   55   66   76   88   96 
>     103  114  123  131                                       
>       138  147  155  167  176  184  192  198  209  216  224  233  242 
>     246  255                                                       
>       262  274  279  290  297  301  310  316  320  326  330  339  345 
>     352  360                                                       
>       368  377  385  393  402  413  421  433  441  448  455  464  468 
>     476  484                                                       
>       492  499  507  515  521  531  539  547  556  564  572  580  588 
>     597  611                                                       
>       625  636  642  651  659  663  670  677  683  692  700  707  715 
>     723  734                                                       
>       740  748  754  762  771  779  787  795  804  816  822  830  842 
>     848  856                                                       
>       865  873  881  890  895  903  912  920  932  944  953  962  970 
>     977  985                                                       
>       993 1000 1012 1021 1029 1038 1046 1057 1063 1071 1079 1085 1093
>     1099 1107                                                       
>      1114 1120 1128 1137 1145 1153 1162 1170 1179 1188 1197 1209 1218
>     1225 1233                                                       
>      1242 1250 1256 1264 1271 1278 1286 1293 1299 1308 1317 1324 1332
>     1340 1350                                                       
>      1358 1369 1376 1382 1388 1396 1403 1411 1420 1432 1440 1447 1455
>     1462 1466                                                       
>      1472 1480 1485 1491 1500 1508 1514 1518 1522 1531 1540 1549 1560
>     1568 1574                                                       
>      1582 1587 1598 1603 1611 1619 1630 1638 1645 1654 1662 1670 1678
>     1686 1694                                                       
>      1703 1708 1715 1721 1727 1735 1743 1751 1760 1766 1775 1787 1795
>     1802 1811                                                       
>      1820 1827 1835 1843 1851 1859 1868 1872 1880 1889 1897 1908 1916
>     1923 1931                                                       
>      1939 1947 1952 1962 1973 1981 1987 1994 2002 2013 2025 2030 2038
>     2045 2053                                                       
>      2064 2071 2079 2085 2093 2104 2113 2124 2130 2138 2146 2154 2162
>     2170 2178                                                       
>      2186 2194 2202 2210 2218 2226 2234 2242 2250 2258 2266 2274 2282
>     2290]                                                           
>
>     [len_i] =  [2300] 
>
>     (index, [len_i]) =  (array([   0,    9,   20,   29,   37,   44,  
>     55,   66,   76,   88,   96,
>             103,  114,  123,  131,  138,  147,  155,  167,  176, 
>     184,  192,                    
>             198,  209,  216,  224,  233,  242,  246,  255,  262, 
>     274,  279,                    
>             290,  297,  301,  310,  316,  320,  326,  330,  339, 
>     345,  352,                    
>             360,  368,  377,  385,  393,  402,  413,  421,  433, 
>     441,  448,                    
>             455,  464,  468,  476,  484,  492,  499,  507,  515, 
>     521,  531,                    
>             539,  547,  556,  564,  572,  580,  588,  597,  611, 
>     625,  636,                    
>             642,  651,  659,  663,  670,  677,  683,  692,  700, 
>     707,  715,                    
>             723,  734,  740,  748,  754,  762,  771,  779,  787, 
>     795,  804,                    
>             816,  822,  830,  842,  848,  856,  865,  873,  881, 
>     890,  895,                    
>             903,  912,  920,  932,  944,  953,  962,  970,  977, 
>     985,  993,                    
>            1000, 1012, 1021, 1029, 1038, 1046, 1057, 1063, 1071, 1079,
>     1085,                    
>            1093, 1099, 1107, 1114, 1120, 1128, 1137, 1145, 1153, 1162,
>     1170,                    
>            1179, 1188, 1197, 1209, 1218, 1225, 1233, 1242, 1250, 1256,
>     1264,                    
>            1271, 1278, 1286, 1293, 1299, 1308, 1317, 1324, 1332, 1340,
>     1350,                    
>            1358, 1369, 1376, 1382, 1388, 1396, 1403, 1411, 1420, 1432,
>     1440,                    
>            1447, 1455, 1462, 1466, 1472, 1480, 1485, 1491, 1500, 1508,
>     1514,                    
>            1518, 1522, 1531, 1540, 1549, 1560, 1568, 1574, 1582, 1587,
>     1598,                    
>            1603, 1611, 1619, 1630, 1638, 1645, 1654, 1662, 1670, 1678,
>     1686,                    
>            1694, 1703, 1708, 1715, 1721, 1727, 1735, 1743, 1751, 1760,
>     1766,                    
>            1775, 1787, 1795, 1802, 1811, 1820, 1827, 1835, 1843, 1851,
>     1859,                    
>            1868, 1872, 1880, 1889, 1897, 1908, 1916, 1923, 1931, 1939,
>     1947,                    
>            1952, 1962, 1973, 1981, 1987, 1994, 2002, 2013, 2025, 2030,
>     2038,                    
>            2045, 2053, 2064, 2071, 2079, 2085, 2093, 2104, 2113, 2124,
>     2130,                    
>            2138, 2146, 2154, 2162, 2170, 2178, 2186, 2194, 2202, 2210,
>     2218,                    
>            2226, 2234, 2242, 2250, 2258, 2266, 2274, 2282, 2290]),
>     [2300])  
>
>  
>
>                         
>      index[1:] =  [   9   20   29   37   44   55   66   76   88   96 
>     103  114  123  131  138
>       147  155  167  176  184  192  198  209  216  224  233  242  246 
>     255  262                   
>       274  279  290  297  301  310  316  320  326  330  339  345  352 
>     360  368                   
>       377  385  393  402  413  421  433  441  448  455  464  468  476 
>     484  492                   
>       499  507  515  521  531  539  547  556  564  572  580  588  597 
>     611  625                   
>       636  642  651  659  663  670  677  683  692  700  707  715  723 
>     734  740                   
>       748  754  762  771  779  787  795  804  816  822  830  842  848 
>     856  865                   
>       873  881  890  895  903  912  920  932  944  953  962  970  977 
>     985  993                   
>      1000 1012 1021 1029 1038 1046 1057 1063 1071 1079 1085 1093 1099
>     1107 1114                   
>      1120 1128 1137 1145 1153 1162 1170 1179 1188 1197 1209 1218 1225
>     1233 1242                   
>      1250 1256 1264 1271 1278 1286 1293 1299 1308 1317 1324 1332 1340
>     1350 1358                   
>      1369 1376 1382 1388 1396 1403 1411 1420 1432 1440 1447 1455 1462
>     1466 1472                   
>      1480 1485 1491 1500 1508 1514 1518 1522 1531 1540 1549 1560 1568
>     1574 1582                   
>      1587 1598 1603 1611 1619 1630 1638 1645 1654 1662 1670 1678 1686
>     1694 1703                   
>      1708 1715 1721 1727 1735 1743 1751 1760 1766 1775 1787 1795 1802
>     1811 1820                   
>      1827 1835 1843 1851 1859 1868 1872 1880 1889 1897 1908 1916 1923
>     1931 1939                   
>      1947 1952 1962 1973 1981 1987 1994 2002 2013 2025 2030 2038 2045
>     2053 2064                   
>      2071 2079 2085 2093 2104 2113 2124 2130 2138 2146 2154 2162 2170
>     2178 2186                   
>      2194 2202 2210 2218 2226 2234 2242 2250 2258 2266 2274 2282 2290
>     2300]                       
>
>     index[:-1] =  [   0    9   20   29   37   44   55   66   76   88  
>     96  103  114  123  131
>       138  147  155  167  176  184  192  198  209  216  224  233  242 
>     246  255             
>       262  274  279  290  297  301  310  316  320  326  330  339  345 
>     352  360             
>       368  377  385  393  402  413  421  433  441  448  455  464  468 
>     476  484             
>       492  499  507  515  521  531  539  547  556  564  572  580  588 
>     597  611             
>       625  636  642  651  659  663  670  677  683  692  700  707  715 
>     723  734             
>       740  748  754  762  771  779  787  795  804  816  822  830  842 
>     848  856             
>       865  873  881  890  895  903  912  920  932  944  953  962  970 
>     977  985             
>       993 1000 1012 1021 1029 1038 1046 1057 1063 1071 1079 1085 1093
>     1099 1107             
>      1114 1120 1128 1137 1145 1153 1162 1170 1179 1188 1197 1209 1218
>     1225 1233             
>      1242 1250 1256 1264 1271 1278 1286 1293 1299 1308 1317 1324 1332
>     1340 1350             
>      1358 1369 1376 1382 1388 1396 1403 1411 1420 1432 1440 1447 1455
>     1462 1466             
>      1472 1480 1485 1491 1500 1508 1514 1518 1522 1531 1540 1549 1560
>     1568 1574             
>      1582 1587 1598 1603 1611 1619 1630 1638 1645 1654 1662 1670 1678
>     1686 1694             
>      1703 1708 1715 1721 1727 1735 1743 1751 1760 1766 1775 1787 1795
>     1802 1811             
>      1820 1827 1835 1843 1851 1859 1868 1872 1880 1889 1897 1908 1916
>     1923 1931             
>      1939 1947 1952 1962 1973 1981 1987 1994 2002 2013 2025 2030 2038
>     2045 2053             
>      2064 2071 2079 2085 2093 2104 2113 2124 2130 2138 2146 2154 2162
>     2170 2178             
>      2186 2194 2202 2210 2218 2226 2234 2242 2250 2258 2266 2274 2282
>     2290]                 
>      mask =  [ True  True  True  True  True  True  True  True  True 
>     True  True  True 
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True False  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True False False False False
>     False                
>      False False False False False False False False False False False
>     False                
>      False False False False False False False False False False False
>     False                
>      False False False False False False False False False False False
>     False                
>      False False  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True                
>       True  True  True  True  True  True  True  True  True  True 
>     True  True
>       True  True  True  True  True  True  True  True  True  True 
>     True  True
>       True  True  True  True  True  True  True  True  True  True 
>     True  True
>       True  True  True False False  True  True  True  True  True 
>     True  True
>       True  True  True  True  True  True  True  True  True  True 
>     True  True
>       True  True  True  True  True  True  True  True  True  True 
>     True  True
>       True  True  True  True  True  True  True  True  True  True 
>     True  True
>       True  True  True  True  True  True  True  True  True]
>
>     N.int32 =  <type 'numpy.int32'>
>
>     delta.astype(N.int32) =  [ 9 11  9  8  7 11 11 10 12  8  7 11  9 
>     8  7  9  8 12  9  8  8  6 11  7  8
>       9  9  4  9  7 12  5 11  7  4  9  6  4  6  4  9  6  7  8  8  9 
>     8  8  9 11
>       8 12  8  7  7  9  4  8  8  8  7  8  8  6 10  8  8  9  8  8  8 
>     8  9 14 14
>      11  6  9  8  4  7  7  6  9  8  7  8  8 11  6  8  6  8  9  8  8 
>     8  9 12  6
>       8 12  6  8  9  8  8  9  5  8  9  8 12 12  9  9  8  7  8  8  7
>     12  9  8  9
>       8 11  6  8  8  6  8  6  8  7  6  8  9  8  8  9  8  9  9  9 12 
>     9  7  8  9
>       8  6  8  7  7  8  7  6  9  9  7  8  8 10  8 11  7  6  6  8  7 
>     8  9 12  8
>       7  8  7  4  6  8  5  6  9  8  6  4  4  9  9  9 11  8  6  8  5
>     11  5  8  8
>      11  8  7  9  8  8  8  8  8  9  5  7  6  6  8  8  8  9  6  9 12 
>     8  7  9  9
>       7  8  8  8  8  9  4  8  9  8 11  8  7  8  8  8  5 10 11  8  6 
>     7  8 11 12
>       5  8  7  8 11  7  8  6  8 11  9 11  6  8  8  8  8  8  8  8  8 
>     8  8  8  8
>       8  8  8  8  8  8  8  8 10]
>
>
>
> Do you have any idea what's wrong? Any advice will be greatly appreciated.
>
> Tom
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>   



More information about the NumPy-Discussion mailing list