关于以下代码,我有两个问题:
当我编译它时,我得到警告/错误"无法将任何[]'转换为'数组'".这是因为public songPaths: Array = []不合法,我应该去public songPaths: any = []吗?
是Object一个合适的默认值public song:Object = new Audio()?
例:
'use strict';
class Boombox{
constructor(public track: number, public codec: string, public song:Object = new Audio(), public currentTime: number = 0, public playing:bool = false, public titles: any = [], public songPaths: Array = []){
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在SciPy interp1d函数的边界设置行为,根据文档应该是可能的:
Behavior at the boundary can be specified at instantiation time.
Run Code Online (Sandbox Code Playgroud)
但我还没有找到任何进一步的信息. 该interp1d文件没有提到这一切.
那么:我该如何定义行为呢?
好奇心:它使用的默认边界行为是什么?
编辑:实例(假设之间的数据点x=0和x=n和三次插值)
我知道至少有三种类型的边界行为,我希望能够指定:
flat:我可以要求函数变平,换句话说,推导为零.
f'(0) = f'(n) = 0
f''(0) = f''(n) = 0
Run Code Online (Sandbox Code Playgroud)
循环:在某些行之间
f'(0) = f'(n)
f''(0) = f''(n)
Run Code Online (Sandbox Code Playgroud)
因此,开始和结束具有相同的"斜率".
手册:或者我可以手动提供衍生品的价值......
f'(0) = ...
f'(n) = ...
f''(0) = ...
f''(n) = ...
Run Code Online (Sandbox Code Playgroud)
虽然可能不是同时针对所有四个人.
有可能以某种方式覆盖Meteor中的方法吗?或者定义另一个函数,以便两者都被调用?
在我的常规代码中:
Meteor.methods(
foo: (parameters) ->
bar(parameters)
)
Run Code Online (Sandbox Code Playgroud)
在其他地方稍后加载(例如tests):
Meteor.methods(
# override
foo: (parameters) ->
differentBehavior(parameters)
# I could call some super() here
)
Run Code Online (Sandbox Code Playgroud)
所以,我希望要么同时拥有bar和differentBehavior执行,或者只是differentBehavior一些可能性来调用super().
这存在吗?
我正在尝试在分派操作时更改URL参数。它链接到实验中的下一个“案例”,并在URL中以整数形式显示。
我如何想象:
初始URL /experiment/2
分派操作{ type: 'NEXT_CASE' }
新URL/experiment/3
研究
基于此答案(尽管有关于redux-router),我想到可以通过访问还原器中的当前路径/ URL store.getState().routing。
但是我想要在路由中定义和解析的参数。(显然,我可以从路径中手动解析它们,但是如果路径结构发生更改,那似乎是不可扩展的,也不是面向未来的。)
当前解决方案
到目前为止,我基于匹配的最佳尝试(他们说这不适合客户端使用):
export default store => next => (action:Action<any>) => {
if (action.type == Types.NEXT_CASE) {
match(
{ routes: Routes, location: store.getState().routing.locationBeforeTransitions.pathname },
(error, redirectLocation, renderProps: any) => browserHistory.push(RouteBuilder.experiment(parseInt(renderProps.params.caseIndex) + 1))
);
}
return next(action);
}
Run Code Online (Sandbox Code Playgroud)
其中Routes和RouteBuilder定义如下:
export const RouteBuilder = {
experiment: (caseIndex: number) => `/experiment/${ caseIndex }`
};
export const Routes …Run Code Online (Sandbox Code Playgroud) 我安装了CMocka 测试框架并尝试了示例代码:
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
/* A test case that does nothing and succeeds. */
static void null_test_success(void **state) {
(void) state; /* unused */
}
int main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(null_test_success),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试编译时,出现以下错误:
$ gcc -o Tests tests.c
/tmp/ccbwAXrr.o: In function `main':
tests.c:(.text+0x5e): undefined reference to `_cmocka_run_group_tests'
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
c ×1
cmocka ×1
gcc ×1
linker ×1
meteor ×1
python ×1
react-router ×1
redux ×1
scipy ×1
typescript ×1