I am running a @nb.njit function within which I am trying to put an integer within a string array.
import numpy as np
import numba as nb
@nb.njit(nogil=True)
def func():
my_array = np.empty(6, dtype=np.dtype("U20"))
my_array[0] = np.str(2.35646)
return my_array
if __name__ == '__main__':
a = func()
print(a)
Run Code Online (Sandbox Code Playgroud)
I am getting the following error :
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<class 'str'>) with argument(s) of type(s): (float64)
Run Code Online (Sandbox Code Playgroud)
Which function am I supposed to use …
我使用Excel 2010和VBA.
我有以下代码:
mySh.PageSetup.PaperSize = xlPaperLetter
mySh.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=filePathTmp, _
Quality:=xlQualityStandard, IncludeDocProperties:=False, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Run Code Online (Sandbox Code Playgroud)
它生成PDF没有错误,但大小不正确.我得到22.26 x 28.80 cm而不是我想要的21.59 x 27.94 cm.
有任何想法吗 ?
谢谢你的帮助
我想创建一个颜色函数,当值为负时显示红色,否则在barChart中显示绿色.
这是我到目前为止所提出的:
var colorChoice = d3.scale.ordinal().domain(["positive","negative"])
.range(["#00FF00","#FF0000"]);
hitsPerDaybarChart
.colors(function(d) {return(colorChoice((d.hits>0) ? "positive":"negative"));})
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误消息:TypeError: Object function (d) {return(colorChoice((d.pnl>0) ? "positive":"negative"));} has no method 'range'.
欢迎所有帮助.谢谢.
我需要在切片上添加边框,因为我有一些相邻的切片使用相同的颜色(我的颜色colorAccessor是正/负->绿色/红色)。
作为奖励,我也希望能够设置标签颜色。
谢谢您的帮助。

这是我的日期时间barChart.当我使用小提琴(见此处)尝试复制问题时,它按预期工作.注意:从github加载数据需要一段时间(~30秒).
以下是图表的代码:
pnlPerDaybarChart
.height(300)
.width(700)
.dimension(dims.date)
.group(groups.date.pnlSum)
.valueAccessor(function(d) {
return Math.abs(d.value);
})
.renderTitle(false)
.x(d3.time.scale().domain([minDate,maxDate]))
.xUnits(d3.time.days)
.colors(colorChoice)
.colorAccessor(function(d) {
if (+d.value>0) {
return("positive");
} else {
return("negative");
}
})
.brushOn(true)
.elasticY(true)
.margins({left: 70 ,top: 10, bottom: 30, right: 50})
.centerBar(true);
Run Code Online (Sandbox Code Playgroud)
我错过了一些明显的东西吗?如果没有,我应该开始调试的任何想法?我花了相当多的时间在这个上面,我找不到任何错误.
编辑:当我删除.xUnits指令时,我得到非常瘦的条,但沿着轴放置得很好.这让我觉得计算条形宽度有问题.我不知道如何调试那个特定的计算.如果有人知道,我会很乐意深入研究它.
EDIT2:所有元素的width属性都设置为错误的值.如果有人能指出我在图书馆计算的地方,我可以从那里拿走它.<g class="chart-body"><g class="stack _0"><rect class="bar"></rect></g></g>svgd3
EDIT3:我找到了问题的根源.条形的宽度不正确,因为当calculateBarWidth()运行一次以实例化图形时,即使调用dc.redrawAll(),它也不再运行.在我的情况下,我连续添加了大量的记录到我的crossfilter并重绘图表.新问题是'如何强制calculateBarWidth()重新运行?'
我有几个层次的深Javscript对象。除了最终级别(我需要排序的数组)以外,所有级别都是对象。
到目前为止,我的代码如下所示:
for (let group in objRes) {
if (objRes.hasOwnProperty(group)) {
for (let type in objRes[group]) {
if (objRes[group].hasOwnProperty(type)) {
for (let name in objRes[group][type]) {
if (objRes[group][type].hasOwnProperty(name)) {
for (let tenor in objRes[group][type][name]) {
if (objRes[group][type][name].hasOwnProperty(tenor)) {
objRes[group][type][name][tenor] = objRes[group][type][name][tenor].sort((x,y)=>x.date>y.date);
}
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
水平(group,type,name,tenor)都是字符串和最后一级数组成员如下所示:{date:'2019-12-25',value:35}
所以objRes看起来像
{
group1:
{type1:
{name1:
{tenor1:[{date:'2019-12-25',value:35},...],
name2 :{...}
}
},
{type2 :{...}},
group2:{...}
}
Run Code Online (Sandbox Code Playgroud)
有什么聪明的方法可以简化这个过程吗?
您可以假定级别数未知。