/** Test of setTopicCount method, of class LatentDirichletAllocationVectorGibbsSampler. */ @Test public void testSetTopicCount() { int topicCount = LatentDirichletAllocationVectorGibbsSampler.DEFAULT_TOPIC_COUNT; LatentDirichletAllocationVectorGibbsSampler instance = new LatentDirichletAllocationVectorGibbsSampler(); assertEquals(topicCount, instance.getTopicCount()); topicCount = 77; instance.setTopicCount(topicCount); assertEquals(topicCount, instance.getTopicCount()); boolean exceptionThrown = false; try { instance.setTopicCount(0); } catch (IllegalArgumentException e) { exceptionThrown = true; } finally { assertTrue(exceptionThrown); } assertEquals(topicCount, instance.getTopicCount()); exceptionThrown = false; try { instance.setTopicCount(-1); } catch (IllegalArgumentException e) { exceptionThrown = true; } finally { assertTrue(exceptionThrown); } assertEquals(topicCount, instance.getTopicCount()); }
/** Test of constructors of class LatentDirichletAllocationVectorGibbsSampler. */ @Test public void testConstructors() { int topicCount = LatentDirichletAllocationVectorGibbsSampler.DEFAULT_TOPIC_COUNT; double alpha = LatentDirichletAllocationVectorGibbsSampler.DEFAULT_ALPHA; double beta = LatentDirichletAllocationVectorGibbsSampler.DEFAULT_BETA; int maxIterations = LatentDirichletAllocationVectorGibbsSampler.DEFAULT_MAX_ITERATIONS; int burnInIterations = LatentDirichletAllocationVectorGibbsSampler.DEFAULT_BURN_IN_ITERATIONS; int iterationsPerSample = LatentDirichletAllocationVectorGibbsSampler.DEFAULT_ITERATIONS_PER_SAMPLE; LatentDirichletAllocationVectorGibbsSampler instance = new LatentDirichletAllocationVectorGibbsSampler(); assertEquals(topicCount, instance.getTopicCount()); assertEquals(alpha, instance.getAlpha(), 0.0); assertEquals(beta, instance.getBeta(), 0.0); assertEquals(maxIterations, instance.getMaxIterations()); assertEquals(burnInIterations, instance.getBurnInIterations()); assertEquals(iterationsPerSample, instance.getIterationsPerSample()); assertNotNull(instance.getRandom()); topicCount = 1 + random.nextInt(100); alpha = random.nextDouble() * 10.0; beta = random.nextDouble() * 10.0; maxIterations = 1 + random.nextInt(100000); burnInIterations = random.nextInt(1000); iterationsPerSample = random.nextInt(100); instance = new LatentDirichletAllocationVectorGibbsSampler( topicCount, alpha, beta, maxIterations, burnInIterations, iterationsPerSample, random); assertEquals(topicCount, instance.getTopicCount()); assertEquals(alpha, instance.getAlpha(), 0.0); assertEquals(beta, instance.getBeta(), 0.0); assertEquals(maxIterations, instance.getMaxIterations()); assertEquals(burnInIterations, instance.getBurnInIterations()); assertEquals(iterationsPerSample, instance.getIterationsPerSample()); assertSame(random, instance.getRandom()); }