我是Angular的新手,我的项目需要一些起点.如何通过鼠标单击背景从ajax数据创建新表?我知道ajax数据的列数未知,并且可能会不时有所不同.
例如:
the first click on background = table 1, ajax request to /api/table
| A | B | C |
| 1 | 2 | 3 |
| 5 | 7 | 9 |
the second click on background = table 2 and server returns new data from the same url /api/table
| X | Y |
| 5 | 3 |
| 8 | 9 |
Run Code Online (Sandbox Code Playgroud) 如何使用正则表达式(或pyparsing更好?)来描述下面提供的脚本语言(Backus-Naur Form):
<root> := <tree> | <leaves>
<tree> := <group> [* <group>]
<group> := "{" <leaves> "}" | <leaf>;
<leaves> := {<leaf>;} leaf
<leaf> := <name> = <expression>{;}
<name> := <string_without_spaces_and_tabs>
<expression> := <string_without_spaces_and_tabs>
Run Code Online (Sandbox Code Playgroud)
脚本示例:
{
stage = 3;
some.param1 = [10, 20];
} *
{
stage = 4;
param3 = [100,150,200,250,300]
} *
endparam = [0, 1]
Run Code Online (Sandbox Code Playgroud)
我使用python re.compile并希望将所有内容分组,如下所示:
[ [ 'stage', '3'],
[ 'some.param1', '[10, 20]'] ],
[ ['stage', '4'],
['param3', '[100,150,200,250,300]'] ],
[ ['endparam', '[0, 1]'] ] …Run Code Online (Sandbox Code Playgroud) 我有索引数组
a = np.array([
[0, 0],
[1, 1],
[1, 9]
])
Run Code Online (Sandbox Code Playgroud)
和2D阵列
b = np.array([
[0, 1, 2, 3],
[5, 6, 7, 8]
])
Run Code Online (Sandbox Code Playgroud)
我可以做到这一点
b[a[:, 0], a[:, 1]]
Run Code Online (Sandbox Code Playgroud)
但这是“ 超出范围 ” 的例外,因为9超出范围。我需要一种非常快速的方法来按索引制作数组切片,如果可以设置裁剪值,这将是理想的选择,例如:
np.indexing_with_clipping(array=b, indices=a, clipping_value=0)
> array([0, 6, --> 0 = clipped value <--])
Run Code Online (Sandbox Code Playgroud) 我使用Intel Xeon x2(24内核)和Windows Server 2008.
尝试并行化我的c ++程序.这里的模板代码:
vector< string > files;
vector< vector< float > > data;
...
data.resize( files.size() );
#pragma omp parallel for
for (int i=0; i<files.size(); i++) { // Files count is about 3000
FILE *f = fopen(files[i].c_str(), "rb");
// every file is about 40 mb
data[i].resize(someSize);
fread(&data[i][0], sizeof(float), someSize, f);
fclose(f);
...
performCalculations();
}
Run Code Online (Sandbox Code Playgroud)
CPU使用率仅为0到5%.
当我插入而不是fread(&data [i] [0],sizeof(float),someSize,f):
for (int j=0; j<data.size(); j++) {
data[i][j] = rand();
}
Run Code Online (Sandbox Code Playgroud)
CPU使用率增加到100%.
我已经尝试过使用fstream和WinApi ReadFile,但它没有产生太大影响.
我究竟做错了什么?我不相信磁盘读数会这么慢......