Skip to content

Commit

Permalink
I didn't realize upgrading my util library would cause these bugs
Browse files Browse the repository at this point in the history
Also took the opportunity to remove some unnecessary code.
  • Loading branch information
matt-gardner committed Aug 26, 2016
1 parent e392d63 commit f72d25d
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public class RandomWalkPathFinder implements WalkUpdateFunction<EmptyType, Integ
private final List<NodePairInstance> instances;
private final EdgeExcluder edgeExcluder;
private final VertexIdTranslate vertexIdTranslate;
private final Object printLock = new Object();

private double resetProbability = 0.35;

Expand Down Expand Up @@ -94,7 +93,7 @@ public RandomWalkPathFinder(GraphOnDisk graph,
origSources.add(instance.source());
origTargets.add(instance.target());
}
this.pathDict = new MutableConcurrentIndex<PathType>(pathTypeFactory, false, new FileUtil());
this.pathDict = new MutableConcurrentIndex<PathType>(pathTypeFactory, new FileUtil());
// We add these to a set first, so we don't start twice as many walks from a node that shows up
// twice in the training data. You could argue that those nodes should have more influence on
// the resultant paths, and that's fair, but it also slows down the computation by quite a bit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import java.rmi.RemoteException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import junit.framework.TestCase;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import edu.cmu.graphchi.walks.distributions.DiscreteDistribution;
Expand All @@ -17,13 +15,10 @@
import edu.cmu.ml.rtw.pra.graphs.GraphOnDisk;
import com.mattg.util.FileUtil;
import com.mattg.util.MutableConcurrentIndex;
import com.mattg.util.Pair;

public class RandomWalkPathFinderCompanionTest extends TestCase {
private int sourceNode = 1;
private int targetNode = 2;
private Pair<Integer, Integer> sourceTargetPair =
new Pair<Integer, Integer>(sourceNode, targetNode);
private int intermediateNode = 3;
private GraphOnDisk graph = new GraphOnDisk("src/test/resources/", Outputter.justLogger(), new FileUtil());
private BasicPathTypeFactory factory = new BasicPathTypeFactory(graph);
Expand All @@ -35,14 +30,13 @@ public class RandomWalkPathFinderCompanionTest extends TestCase {
private PathType type13 = factory.fromString("-1-3-");
private PathType type22 = factory.fromString("-2-2-");
private PathType type23 = factory.fromString("-2-3-");
private MutableConcurrentIndex<PathType> pathDict = new MutableConcurrentIndex<PathType>(factory, false, new FileUtil());
private MutableConcurrentIndex<PathType> pathDict = new MutableConcurrentIndex<PathType>(factory, new FileUtil());
private int type1Index = pathDict.getIndex(type1);
private int type2Index = pathDict.getIndex(type2);
private int type_2Index = pathDict.getIndex(type_2);
private int type_3Index = pathDict.getIndex(type_3);

private NodePairInstance instance = new NodePairInstance(sourceNode, targetNode, true, graph);
private List<NodePairInstance> instances = Lists.newArrayList();

private void setDistributionsForTest(RandomWalkPathFinderCompanion companion) {
// We'll have one source, one target, and one intermediate node in this test.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package edu.cmu.ml.rtw.pra.features;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import junit.framework.TestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import java.rmi.RemoteException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import junit.framework.TestCase;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import edu.cmu.graphchi.walks.distributions.DiscreteDistribution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package edu.cmu.ml.rtw.pra.features;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;

import junit.framework.TestCase;

Expand All @@ -18,9 +16,7 @@
import edu.cmu.ml.rtw.pra.graphs.GraphOnDisk;
import com.mattg.util.FakeRandom;
import com.mattg.util.FileUtil;
import com.mattg.util.MapUtil;
import com.mattg.util.Pair;
import com.mattg.util.TestUtil;

public class RandomWalkPathFollowerTest extends TestCase {
private List<Pair<Pair<Integer, Integer>, Integer>> edgesToExclude = Lists.newArrayList();
Expand Down Expand Up @@ -95,9 +91,6 @@ public void testProcessWalks() {
}

public void testProcessSingleWalk() {
Map<Integer, List<Integer>> inEdgeMap = Maps.newHashMap();
Map<Integer, List<Integer>> outEdgeMap = Maps.newHashMap();

int pathType = 0;
int hopNum = 0;
int sourceId = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.mattg.util.Vector;

public class VectorClusteringPathTypeSelectorTest extends TestCase {
private MutableConcurrentDictionary edgeDict = new MutableConcurrentDictionary(false, new FileUtil());
private MutableConcurrentDictionary edgeDict = new MutableConcurrentDictionary(new FileUtil());
private GraphInMemory graph = new GraphInMemory(new Node[0], null, edgeDict);
private Map<Integer, Vector> embeddings = Maps.newHashMap();
private VectorPathTypeFactory factory = new VectorPathTypeFactory(graph, embeddings, 1, .5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class VectorPathTypeFactoryTest extends TestCase {
private Vector vector2 = new Vector(new double[]{-1,-2,-3});
private Vector vector3 = new Vector(new double[]{1,3,3});
private Map<Integer, Vector> embeddings = Maps.newHashMap();
private MutableConcurrentDictionary edgeDict = new MutableConcurrentDictionary(false, new FileUtil());
private MutableConcurrentDictionary edgeDict = new MutableConcurrentDictionary(new FileUtil());
private GraphInMemory graph = new GraphInMemory(new Node[0], null, edgeDict);

@Override
Expand Down Expand Up @@ -64,7 +64,6 @@ public void testGetNextEdgeTypeWorksCorrectly() {
FakeRandom random = new FakeRandom();

int hopNum = 0;
int sourceId = 0;

PathTypeVertexCache cache = pathType.cacheVertexInformation(vertex, hopNum);

Expand Down

0 comments on commit f72d25d

Please sign in to comment.