Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,23 @@ export abstract class SearchQuotientSpur implements SearchQuotientNode {

return components.join('+');
}
}

/**
* Provides a unique hash-style string corresponding to the edge represented
* by this graph spur.
*
* This is designed for use in two cases:
* 1. At runtime - plays a role in simplification of results for .split
* operations with SearchQuotientCluster ancestry, which may cause
* quotient-paths that diverge and reconverge during recursion
* - Specifically, this property assists detection of duplicate instances
* during 'diverged' states, allowing reconvergence to be handled.
* 2. In unit tests - validating that splits with SearchQuotientCluster
* ancestry properly handle quotient-path variance in unit tests.
*/
get edgeKey(): string {
const inputSrc = this.inputSource;
const segment = inputSrc.segment;
return `E${inputSrc.subsetId}:${segment.start}${segment.end !== undefined ? `-${segment.end}` : ''}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,67 @@ describe('SearchQuotientSpur', () => {
});
});

describe('.edgeKey', () => {
it('changes when input source subset IDs differ', () => {
const root = new LegacyQuotientRoot(testModel);

const {distributions} = buildSimplePathSplitFixture();
const inputSrc = {
segment: {
transitionId: distributions[0][0].sample.id,
start: 0
},
subsetId: generateSubsetId(),
bestProbFromSet: distributions[0][0].p
};

const spur1 = new LegacyQuotientSpur(root, distributions[0], {
...inputSrc,
subsetId: generateSubsetId()
});
const spur2 = new LegacyQuotientSpur(root, distributions[0], {
...inputSrc,
subsetId: generateSubsetId()
});

assert.notEqual(spur1.edgeKey, spur2.edgeKey);
});

it('changes when different parts of the same input source are used', () => {
const root = new LegacyQuotientRoot(testModel);

const {distributions} = buildSimplePathSplitFixture();
const inputSrc = {
segment: {
transitionId: distributions[0][0].sample.id,
start: 0
},
subsetId: generateSubsetId(),
bestProbFromSet: distributions[0][0].p
};

const spur1 = new LegacyQuotientSpur(root, distributions[0], inputSrc);
const spur2 = new LegacyQuotientSpur(root, distributions[0], {
...inputSrc,
segment: {
...inputSrc.segment,
end: 1
}
});
const spur3 = new LegacyQuotientSpur(root, distributions[0], {
...inputSrc,
segment: {
...inputSrc.segment,
start: inputSrc.segment.start + 1
}
});

assert.notEqual(spur1.edgeKey, spur2.edgeKey);
assert.notEqual(spur2.edgeKey, spur3.edgeKey);
assert.notEqual(spur3.edgeKey, spur1.edgeKey);
});
});

describe('split()', () => {
describe(`on token comprised of single-char transforms: [crt][ae][nr][t]`, () => {
const runSplit = (splitIndex: number) => {
Expand Down