當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Uint64.parseString方法代碼示例

本文整理匯總了TypeScript中neuroglancer/util/uint64.Uint64.parseString方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Uint64.parseString方法的具體用法?TypeScript Uint64.parseString怎麽用?TypeScript Uint64.parseString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在neuroglancer/util/uint64.Uint64的用法示例。


在下文中一共展示了Uint64.parseString方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: fragmentShaderTest

    fragmentShaderTest(3, tester => {
      const shaderManager = new SegmentColorShaderManager('getColor');
      let {gl, builder} = tester;
      shaderManager.defineShader(builder);
      builder.addUniform('highp vec4', 'inputValue', 2);
      const colorHash = SegmentColorHash.getDefault();
      builder.addOutputBuffer('vec4', 'v4f_fragData0', 0);
      builder.addOutputBuffer('vec4', 'v4f_fragData1', 1);
      builder.addOutputBuffer('vec4', 'v4f_fragData2', 2);
      builder.setFragmentMain(`
uint64_t x;
x.low = inputValue[0];
x.high = inputValue[1];

highp vec3 color = getColor(x);
v4f_fragData0 = packFloatIntoVec4(color.x);
v4f_fragData1 = packFloatIntoVec4(color.y);
v4f_fragData2 = packFloatIntoVec4(color.z);
`);
      tester.build();
      let {shader} = tester;
      shader.bind();
      shaderManager.enable(gl, shader, colorHash);

      function testValue(x: Uint64) {
        let temp = new Uint32Array(2);
        temp[0] = x.low;
        temp[1] = x.high;
        let inputValue = encodeBytesToFloat32(temp);
        gl.uniform4fv(shader.uniform('inputValue'), inputValue);
        tester.execute();

        let actual = new Float32Array(3);
        for (let i = 0; i < 3; ++i) {
          actual[i] = tester.readFloat(i);
        }

        let expected = new Float32Array(3);
        colorHash.compute(expected, x);

        expect(actual).toEqual(expected, `x = ${x}`);
      }

      testValue(Uint64.parseString('0'));
      testValue(Uint64.parseString('8'));
      const COUNT = 100;
      for (let iter = 0; iter < COUNT; ++iter) {
        let x = Uint64.random();
        testValue(x);
      }
    });
開發者ID:stephenplaza,項目名稱:neuroglancer,代碼行數:51,代碼來源:segment_color.spec.ts

示例2: mapMetricsToColors

export function mapMetricsToColors(
    IdMetricMap: any, metricKeyData: MetricKeyData): Map<string, Uint64> {
  let colors = ['Yellow', 'aquamarine', 'deepskyblue', 'mediumorchid'];
  let metricIteratee = function(el: ArrayLike<number>) {
    return el[1];  // metric value
  };
  let min = metricKeyData.min = minBy(IdMetricMap, metricIteratee)![1];
  let max = metricKeyData.max = maxBy(IdMetricMap, metricIteratee)![1];
  let scale = metricKeyData.chromaScale = chroma!.scale(colors).domain([min, max]);

  for (let i = 0, len = IdMetricMap.length; i < len; i++) {
    let metricArr = IdMetricMap[i];
    let metricVal = metricArr[1];
    let rgb = (scale(metricVal)).rgba();
    // convert color to 32bit little-endian value
    metricArr[1] = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + rgb[0];
    // make data key
    let idUint64 = new Uint64();
    idUint64.parseString(metricArr[0].toString());
    metricArr[0] = idUint64.low + ',' + idUint64.high;
    // convert val to Uint64 with rand high values
    let randHigh = Math.floor(Math.random() * Math.pow(2, 32));
    metricArr[1] = new Uint64(metricArr[1], randHigh);
  }
  metricKeyData.IDColorMap = new Map<string, Uint64>(IdMetricMap);
  return metricKeyData.IDColorMap;
}
開發者ID:janelia-flyem,項目名稱:neuroglancer,代碼行數:27,代碼來源:metric_color_util.ts

示例3: fragmentShaderTest

    fragmentShaderTest({outR: 'float', outG: 'float', outB: 'float'}, tester => {
      const shaderManager = new SegmentColorShaderManager('getColor');
      let {gl, builder} = tester;
      shaderManager.defineShader(builder);
      builder.addUniform('highp uvec2', 'inputValue');
      const colorHash = SegmentColorHash.getDefault();
      builder.addFragmentCode(glsl_unpackUint64leFromUint32);
      builder.setFragmentMain(`
uint64_t x = unpackUint64leFromUint32(inputValue);

highp vec3 color = getColor(x);
outR = color.r;
outG = color.g;
outB = color.b;
`);
      tester.build();
      let {shader} = tester;
      shader.bind();
      shaderManager.enable(gl, shader, colorHash);

      function testValue(x: Uint64) {
        gl.uniform2ui(shader.uniform('inputValue'), x.low, x.high);
        tester.execute();

        let actual = new Float32Array(3);
        for (let i = 0; i < 3; ++i) {
          actual[i] = tester.readFloat(i);
        }

        let expected = new Float32Array(3);
        colorHash.compute(expected, x);
        const {values} = tester;
        expect(values.outR).toBeCloseTo(expected[0]);
        expect(values.outG).toBeCloseTo(expected[1]);
        expect(values.outB).toBeCloseTo(expected[2]);
      }

      testValue(Uint64.parseString('0'));
      testValue(Uint64.parseString('8'));
      const COUNT = 100;
      for (let iter = 0; iter < COUNT; ++iter) {
        let x = Uint64.random();
        testValue(x);
      }
    });
開發者ID:google,項目名稱:neuroglancer,代碼行數:45,代碼來源:segment_color.spec.ts

示例4: compareViaGet

 function compareViaGet() {
   let value = new Uint64();
   for (let [s, expectedValue] of map) {
     let key = Uint64.parseString(s);
     let has = ht.get(key, value);
     expect(has && Uint64.equal(value, expectedValue))
         .toBe(
             true,
             `Hash table maps ${key} -> ${has ? value : undefined} rather than -> ${expectedValue}`);
   }
 }
開發者ID:janelia-flyem,項目名稱:neuroglancer,代碼行數:11,代碼來源:hash_table.spec.ts

示例5: it

 it('parseString failures', () => {
   let temp = new Uint64(1, 2);
   expect(temp.parseString(' ')).toBe(false);
   expect(temp.parseString(' 0')).toBe(false);
   expect(temp.parseString('0 ')).toBe(false);
   expect(temp.parseString('z')).toBe(false);
   expect(temp.parseString('2', 2)).toBe(false);
   expect(temp.parseString('18446744073709551616')).toBe(false);
   expect(temp.parseString('1')).toBe(true);
 });
開發者ID:j6k4m8,項目名稱:neuroglancer,代碼行數:10,代碼來源:uint64.spec.ts

示例6: it

 it('toJSON', () => {
   let disjointSets = new DisjointUint64Sets();
   disjointSets.link(Uint64.parseString('5'), Uint64.parseString('0'));
   disjointSets.link(Uint64.parseString('2'), Uint64.parseString('10'));
   disjointSets.link(Uint64.parseString('2'), Uint64.parseString('3'));
   expect(JSON.stringify(disjointSets)).toEqual('[["0","5"],["2","3","10"]]');
 });
開發者ID:google,項目名稱:neuroglancer,代碼行數:7,代碼來源:disjoint_sets.spec.ts

示例7: check

 function check(x: Uint64, base: number) {
   let s = x.toString(base);
   let y = Uint64.parseString(s, base);
   expect(y.low).toBe(x.low);
   expect(y.high).toBe(x.high);
 }
開發者ID:janelia-flyem,項目名稱:neuroglancer,代碼行數:6,代碼來源:uint64.spec.ts

示例8: compareViaHas

 function compareViaHas() {
   for (let s of set) {
     let k = Uint64.parseString(s);
     expect(ht.has(k)).toBe(true, `Hash table is missing key ${s}`);
   }
 }
開發者ID:google,項目名稱:neuroglancer,代碼行數:6,代碼來源:hash_table.spec.ts

示例9: check

 function check(x: Uint64, base: number) {
   let s = x.toString(base);
   let y = Uint64.parseString(s, base);
   expect(y.low).toBe(x.low, `s=${s}, x.low=${x.low}, x.high=${x.high}, y.low=${y.low}, y.high=${y.high}, base=${base}`);
   expect(y.high).toBe(x.high, `s=${s}, x.low=${x.low}, x.high=${x.high}, y.low=${y.low}, y.high=${y.high}, base=${base}`);
 }
開發者ID:google,項目名稱:neuroglancer,代碼行數:6,代碼來源:uint64.spec.ts


注:本文中的neuroglancer/util/uint64.Uint64.parseString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。