- add a
prefix: NodeAddressT
parameter to nodesIterator -> tests pass (nothing passed in/ parameter not used) - specify a prefix to pass into nodesIterator from nodes() ie always something, if its empty pass in an empty iterator
-
tests fail; NodeAddress isn't defined
-
imported 'NodeAddress'
- put a test in to see if node has prefix specified in parameter
- Should PagerankGraph be implementing this prefix filter at all, or passing the prefix to graph and let graph filter? why do this at both sites, duplicate tests, etc
- Does node decomposition do this?
We do this in the UI:
nodes={Array.from(pnd.keys()).filter((node) =>
NodeAddress.hasPrefix(node, topLevelFilter)
)}
what are some possible objections to passing the prefex to '_Graph' ?
- need to update nodes iterator first, bc that's what is filtering the nodes
- nodesIterator uses NodeAddress to filter the nodes, which is an AddressModule,
test:
- "uses empty prefix when no options object"
- "requires a prefix when options are specified"
- "does a prefix filter"
- "yields nothing when prefix matches nothing"
How to test?
https://github.com/sourcecred/sourcecred/blob/b51491ce1a4d2462851754f5ed1ad8329d0a3714/src/core/graph.test.js#L537-L661 https://github.com/sourcecred/sourcecred/blob/b51491ce1a4d2462851754f5ed1ad8329d0a3714/src/core/graph.test.js#L351-L386
nodes first
*nodes(options?: {|+prefix: NodeAddressT|}): Iterator<ScoredNode> { }
*edges(options?: EdgesOptions): Iterator<WeightedEdge> { }
it("throws in case of modification count reset", () => {
const g = new Graph();
g.addNode(NodeAddress.fromParts(["stop"]));
const iterator = g.nodes();
g._modificationCount--;
expect(() => {
iterator.next();
}).toThrow("modification count in the future");
});