当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript assert.approximately方法代码示例

本文整理汇总了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");

        });
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:34,代码来源:ScatterPlotUtils.spec.ts

示例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);
}
开发者ID:kiliankoe,项目名称:dvbjs,代码行数:7,代码来源:helper.ts

示例3:

 dvb.findAddress(lng, lat).then((address) => {
   assert.isDefined(address);
   assert.strictEqual(address!.name, "
开发者ID:kiliankoe,项目名称:dvbjs,代码行数:3,代码来源:index.spec.ts


注:本文中的chai.assert.approximately方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。