Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-305

NPE in KMeansPlusPlusClusterer unittest

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.1
    • None
    • None
    • java 6, eclipse, apache commons math trunk

    Description

      When running this unittest, I am facing this NPE:
      java.lang.NullPointerException
      at org.apache.commons.math.stat.clustering.KMeansPlusPlusClusterer.assignPointsToClusters(KMeansPlusPlusClusterer.java:91)

      This is the unittest:

      package org.fao.fisheries.chronicles.calcuation.cluster;

      import static org.junit.Assert.assertEquals;
      import static org.junit.Assert.assertTrue;

      import java.util.Arrays;
      import java.util.List;
      import java.util.Random;

      import org.apache.commons.math.stat.clustering.Cluster;
      import org.apache.commons.math.stat.clustering.EuclideanIntegerPoint;
      import org.apache.commons.math.stat.clustering.KMeansPlusPlusClusterer;
      import org.fao.fisheries.chronicles.input.CsvImportProcess;
      import org.fao.fisheries.chronicles.input.Top200Csv;
      import org.junit.Test;

      public class ClusterAnalysisTest {

      @Test
      public void testPerformClusterAnalysis2() {
      KMeansPlusPlusClusterer<EuclideanIntegerPoint> transformer = new KMeansPlusPlusClusterer<EuclideanIntegerPoint>(
      new Random(1746432956321l));
      EuclideanIntegerPoint[] points = new EuclideanIntegerPoint[] {
      new EuclideanIntegerPoint(new int[]

      { 1959, 325100 }

      ),
      new EuclideanIntegerPoint(new int[]

      { 1960, 373200 }

      ), };
      List<Cluster<EuclideanIntegerPoint>> clusters = transformer.cluster(Arrays.asList(points), 1, 1);
      assertEquals(1, clusters.size());

      }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            erikvaningen Erik van Ingen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified