-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…s-VMT-4ci test summary stats (vehicle miles traveled)
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/test/scala/beam/analysis/plots/VehicleMilesTraveledAnalysisSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |