简体   繁体   English

numana.histogram更新anaconda后失败

[英]numpy.histogram fails after updating anaconda

I have been using the matplotlib function plt.hist to generate histogram data from an array of values mV . 我一直在使用matplotlib函数plt.hist从值mV的数组生成直方图数据。 This has worked fine in the past, but ever since I've updated my version of anaconda it throws back a ValueError : 在过去,这种方法效果很好,但是自从我更新了anaconda版本以来,它就抛出了ValueError

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/users/benjatin/HomeData/Code/buildSkyMap.py in <module>()
     72         #get histogram of efficiencies
     73         plt.figure()
---> 74         a=plt.hist(mV,bins=50)
     75         plt.close()
     76 

/opt/apps/lsst/feb14/Linux64/anaconda/2.1.0/lib/python2.7/site-packages/matplotlib/pyplot.pyc in hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, hold, **kwargs)
   2888                       histtype=histtype, align=align, orientation=orientation,
   2889                       rwidth=rwidth, log=log, color=color, label=label,
-> 2890                       stacked=stacked, **kwargs)
   2891         draw_if_interactive()
   2892     finally:

/opt/apps/lsst/feb14/Linux64/anaconda/2.1.0/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
   5634             # this will automatically overwrite bins,
   5635             # so that each histogram uses the same bins
-> 5636             m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
   5637             m = m.astype(float)  # causes problems later if it's an int
   5638             if mlast is None:

/opt/apps/lsst/feb14/Linux64/anaconda/2.1.0/lib/python2.7/site-packages/numpy/lib/function_base.pyc in histogram(a, bins, range, normed, weights, density)
    598                 n.imag += np.bincount(indices, weights=tmp_w.imag, minlength=bins)
    599             else:
--> 600                 n += np.bincount(indices, weights=tmp_w, minlength=bins).astype(ntype)
    601 
    602         # We now compute the bin edges since these are returned

ValueError: The first argument of bincount must be non-negative

None of the values in mV are negative, as was the problem here : mV中的所有值都不为负,这是这里的问题:

In [34]: mV[mV < 0]
Out[34]: array([], dtype=float64)

The update I did was: 我所做的更新是:

    conda:     3.7.0-py27_0 --> 4.0.5-py27_0 (soft-link)
    openssl:   1.0.1h-1     --> 1.0.2h-0     (soft-link)
    python:    2.7.8-1      --> 2.7.11-0     (soft-link)
    pyyaml:    3.11-py27_0  --> 3.11-py27_1  (soft-link)
    requests:  2.4.1-py27_0 --> 2.9.1-py27_0 (soft-link)
    sqlite:    3.8.4.1-0    --> 3.9.2-0      (soft-link)
    tk:        8.5.15-0     --> 8.5.18-0     (soft-link)
    yaml:      0.1.4-0      --> 0.1.6-0      (soft-link)
    zlib:      1.2.7-0      --> 1.2.8-0      (soft-link)

Thanks in advance for any help solving this issue. 在此先感谢您对解决此问题的任何帮助。

Filter out any nan and inf from your data before plotting the histogram. 在绘制直方图之前,请从数据中过滤掉所有nan和inf。 See the bug report here . 此处查看错误报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM