Skip to content

Instantly share code, notes, and snippets.

@BrianLitwin
Last active February 15, 2019 17:00
Show Gist options
  • Save BrianLitwin/36e8b849da1a45098e950d63df44699d to your computer and use it in GitHub Desktop.
Save BrianLitwin/36e8b849da1a45098e950d63df44699d to your computer and use it in GitHub Desktop.
  1. add a prefix: NodeAddressT parameter to nodesIterator -> tests pass (nothing passed in/ parameter not used)
  2. 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'

  1. 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:

  1. "uses empty prefix when no options object"
  2. "requires a prefix when options are specified"
  3. "does a prefix filter"
  4. "yields nothing when prefix matches nothing"

https://github.com/sourcecred/sourcecred/blob/4914e79655efe77a49bb257e15b99cb810737bd9/src/core/pagerankGraph.js#L169-L225

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");
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment