小编Ang*_*ela的帖子

散景 HoverTool 显示“???”

我正在使用 Python 进入 Bokeh 库,但遇到了一些麻烦。我有来自 Bokeh 教程网站的以下代码:

from bokeh.plotting import figure 
from bokeh.io import output_notebook, show
output_notebook()
from bokeh.sampledata.autompg import autompg
from bokeh.models import HoverTool
from bokeh.plotting import ColumnDataSource

grouped = autompg.groupby("yr")
mpg2 = grouped["mpg"]
avg = mpg2.mean()
std = mpg2.std()
years = list(grouped.groups.keys())
american = autompg[autompg["origin"]==1]
japanese = autompg[autompg["origin"]==3]

p = figure(title="MPG by Year (Japan and US)")

p.vbar(x=years, bottom=avg-std, top=avg+std, width=0.8, 
       fill_alpha=0.2, line_color=None, legend="MPG 1 stddev")

p.circle(x=japanese["yr"], y=japanese["mpg"], size=10, alpha=0.5,
         color="red", legend="Japanese")

p.triangle(x=american["yr"], y=american["mpg"], size=10, alpha=0.3,
           color="blue", legend="American")

p.legend.location …
Run Code Online (Sandbox Code Playgroud)

python bokeh

4
推荐指数
1
解决办法
5803
查看次数

贤者不可变矢量错误

我正在尝试在sage中实现一些东西,并且我不断收到以下错误:

*Error in lines 38-53
Traceback (most recent call last):
  File "/projects/42e45a19-7a43-4495-8dcd-353625dfce66/.sagemathcloud/sage_server.py", line 879, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 13, in <module>
  File "sage/modules/vector_integer_dense.pyx", line 185, in sage.modules.vector_integer_dense.Vector_integer_dense.__setitem__ (build/cythonized/sage/modules/vector_integer_dense.c:3700)
    raise ValueError("vector is immutable; please change a copy instead (use copy())")
ValueError: vector is immutable; please change a copy instead (use copy())*
Run Code Online (Sandbox Code Playgroud)

我已经确定了确切位置(末尾的while循环中"print'标记1'"和"print'标记2'"之间的界限,见下面的代码)似乎我不允许更改循环内部矩阵"权重"(我在循环之前定义)的条目.错误消息说使用copy()函数,但我不知道如何解决我的问题,因为我只会制作一个本地副本,循环的下一次迭代不会得到这些更改的值,对吧?那么有谁知道如何定义这个矩阵,以便我可以从循环内部改变它?如果不可能,有人可以解释原因吗?

谢谢你的帮助.


码:

m = 3  # Dimension of inputs to nodes
n = 1  # Dimension of output
v = 4 …
Run Code Online (Sandbox Code Playgroud)

immutability sage

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

标签 统计

bokeh ×1

immutability ×1

python ×1

sage ×1