Uploaded image for project: 'Mahout'
  1. Mahout
  2. MAHOUT-187

RandomUtils>>isNotPrime throws IllegalArgumentException when argument is less than 2.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.1
    • 0.2
    • None
    • None

    Description

      I was using a FastMap, which happened to be empty, and rehash() was called. Rehash eventually calls isNotPrime where n=1, which throws an illegal argument exception:

      public static boolean isNotPrime(int n) {
      if (n < 2)

      { throw new IllegalArgumentException(); }

      It seems to me anything less than two is not prime. Thus, I suggest:

      public static boolean isNotPrime(int n) {
      if (n < 2)

      { return true; }

      Attachments

        Activity

          People

            srowen Sean R. Owen
            emerson Emerson Murphy-HIll
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: