本文整理汇总了TypeScript中chai.assert.approximately方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.approximately方法的具体用法?TypeScript assert.approximately怎么用?TypeScript assert.approximately使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chai.assert
的用法示例。
在下文中一共展示了assert.approximately方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("gives the correct regression equation, R^2, and function for a sample input with no correlation", ()=>{
const data:[number,number][] = [
[0.10198768, 0.10165061],
[0.10150876, 0.47896164],
[0.30063469, 0.43840858],
[0.24547808, 0.63594344],
[0.05588675, 0.93228701],
[0.95760052, 0.53645723],
[0.02858332, 0.79155903],
[0.49389574, 0.54855519],
[0.77610317, 0.9879552],
[0.00350206, 0.73565457]
];
const computations = getRegressionComputations(data);
// target values computed via python: scipy.stats.linregress
const m = 0.079113612612723011;
const b = 0.59449349756220937;
const r2 = 0.010257434869772463;
// test regression equation to make sure its approximately the same as what python gives
const match = computations.string.match(/y = ([\d.]+)x \+ ([\d.]+)/);
assert.isNotNull(match, "equation has correct form");
const M = parseFloat(match![1]);
const B = parseFloat(match![2]);
assert.approximately(M, m, 0.05);
assert.approximately(B, b, 0.05);
// make sure `predict` gives the same result as the equation
for (let i=0; i<100; i+=1) {
assert.approximately(computations.predict(i)[1], M*i + B, 0.0000005, `value for ${i}`);
}
// test R^2
assert.approximately(computations.r2, r2, 0.05, "R^2");
});
示例2: assertCoords
export function assertCoords(coords: coord) {
assert.isArray(coords);
assert.lengthOf(coords, 2);
assert.approximately(coords[0], 13, 1);
assert.approximately(coords[1], 51, 3);
}
示例3:
dvb.findAddress(lng, lat).then((address) => {
assert.isDefined(address);
assert.strictEqual(address!.name, "