本文整理汇总了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);
}
});
示例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;
}
示例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);
}
});
示例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}`);
}
}
示例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);
});
示例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"]]');
});
示例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);
}
示例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}`);
}
}
示例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}`);
}