fundacion-sadosky / genis

GENis
https://www.fundacionsadosky.org.ar/genis/
GNU Affero General Public License v3.0
7 stars 3 forks source link

MatchingCalculatorService fails in avgLr method #110

Closed javieriserte closed 2 months ago

javieriserte commented 2 months ago

When one of the LRs to average is 0.0, the method fails due to an incomplete pattern matching.

  def avgLr(result1: Option[LRResult], result2: Option[LRResult]):Option[LRResult] = {
    (result1, result2) match {
      case (Some(r1), Some(r2)) if r1.total > 0 && r2.total > 0 =>
        Some(LRResult((r1.total + r2.total) / 2, avgDetailed(r1.detailed, r2.detailed)))
      // There should be an extra case
      //  case (Some(r1), Some(r2)) => ....
      case (Some(r1), None) => result1
      case (None, Some(r2)) => result2
      case (None, None) => result1
    }
  }
javieriserte commented 2 months ago

Fixed in commits:

When one of the two LR results is 0.0 then the other is returned as the average. When both are 0.0, then None is returned.