Skip to content

Commit

Permalink
Merge pull request #1706 from LBNL-UCB-STI/zb/#1705-test-summary-stat…
Browse files Browse the repository at this point in the history
…s-VMT-4ci

test summary stats (vehicle miles traveled)
  • Loading branch information
colinsheppard authored Aug 14, 2019
2 parents e66759d + 82bb883 commit 5224b47
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package beam.analysis.plots

import beam.agentsim.agents.vehicles.BeamVehicleType
import beam.analysis.summary.VehicleMilesTraveledAnalysis
import org.matsim.api.core.v01.Id
import org.scalatest.Matchers

import scala.collection.Set

class VehicleMilesTraveledAnalysisSpec extends GenericAnalysisSpec with Matchers {
var vehicleTypes: Set[Id[BeamVehicleType]] = _

override def beforeAll(): Unit = {
super.beforeAll()

vehicleTypes = beamServices.vehicleTypes.keySet
runAnalysis(new VehicleMilesTraveledAnalysis(vehicleTypes))
}

"Vehicle miles traveled analyser " must {

"calculate total vehicle traveled by vehicle type " in {
vehicleTypes.foreach(t => summaryStats.get(s"motorizedVehicleMilesTraveled_$t") should not be 0)
}

"calculate total vehicle traveled " in {

import scala.collection.JavaConverters._
summaryStats.asScala
.filterNot(_._1.equalsIgnoreCase("motorizedVehicleMilesTraveled_total"))
.filterNot(
_._1.equalsIgnoreCase(s"motorizedVehicleMilesTraveled_${BeamVehicleType.defaultHumanBodyBeamVehicleType.id}")
)
.filterNot(_._1.startsWith("vehicleMilesTraveled_"))
.values
.map(_.doubleValue())
.sum
.round shouldBe
summaryStats.get("motorizedVehicleMilesTraveled_total").doubleValue().round
}
}
}

0 comments on commit 5224b47

Please sign in to comment.