project/analysis/analyzers/__init__.py

76 lines
2.1 KiB
Python

from typing import List
from .analyzer import Analyzer, Result
from .analyzer.biogames import BoardDurationAnalyzer, SimulationRoundsAnalyzer, ActivationSequenceAnalyzer, \
BiogamesCategorizer, ActivityMapper, BiogamesStore, InstanceConfig, SimulationOrderAnalyzer, SimulationCategorizer, \
SimulationFlagsAnalyzer
from .analyzer.default import LogEntryCountAnalyzer, LocationAnalyzer, LogEntrySequenceAnalyzer, ActionSequenceAnalyzer, \
CategorizerStub, Store, ProgressAnalyzer
from .analyzer.locomotion import LocomotionActionAnalyzer, CacheSequenceAnalyzer
from .analyzer.mask import MaskSpatials
from .render import Render
from .render.biogames import SimulationRoundsRender, BoardDurationHistRender, BoardDurationBoxRender, \
ActivityMapperRender, StoreRender, SimulationOrderRender, SimulationGroupRender
from .render.default import PrintRender, JSONRender, TrackRender, HeatMapRender, LogEntryCountAnalyzerPlot, \
LogEntryCountCSV, KMLRender
from .render.locomotion import LocomotionActionRelativeRender, LocomotionActionAbsoluteRender, \
LocomotionActionRatioRender
__FALLBACK__ = PrintRender
__MAPPING__ = {
LocomotionActionAnalyzer: [
LocomotionActionAbsoluteRender,
LocomotionActionRelativeRender,
LocomotionActionRatioRender, ],
LogEntryCountAnalyzer: [
# JSONRender,
LogEntryCountAnalyzerPlot,
LogEntryCountCSV,
],
SimulationRoundsAnalyzer: [
JSONRender,
SimulationRoundsRender,
],
BoardDurationAnalyzer: [
BoardDurationHistRender,
BoardDurationBoxRender,
],
ActivationSequenceAnalyzer: [
JSONRender,
],
LocationAnalyzer: [
TrackRender,
HeatMapRender,
KMLRender,
],
ActivityMapper: [
ActivityMapperRender
],
BiogamesStore: [
StoreRender
],
ProgressAnalyzer: [
StoreRender
],
SimulationOrderAnalyzer: [
#JSONRender,
# SimulationOrderRender,
SimulationGroupRender
]
}
def get_renderer(cls: type) -> [type]:
if cls not in __MAPPING__:
return [__FALLBACK__]
return __MAPPING__[cls]
def render(cls: type, results: List[Result], name=None):
for r in get_renderer(cls):
p = r()
p.result_types.append(cls)
rendered = p.render(results, name=name)
if rendered:
print(str(r))