project/analyzers/__init__.py

41 lines
1.2 KiB
Python

from typing import List
from .analyzer import Analyzer, Result
from .analyzer.biogames import BoardDurationAnalyzer, SimulationRoundsAnalyzer
from .analyzer.default import LogEntryCountAnalyzer, LocationAnalyzer, LogEntrySequenceAnalyzer, ActionSequenceAnalyzer
from .analyzer.locomotion import LocomotionActionAnalyzer, CacheSequenceAnalyzer
from .analyzer.mask import MaskSpatials
from .render import Render
from .render.default import PrintRender, JSONRender
from .render.locomotion import LocomotionActionRelativeRender, LocomotionActionAbsoluteRender, \
LocomotionActionRatioRender
from .render.biogames import SimulationRoundsRender
__FALLBACK__ = PrintRender
__MAPPING__ = {
LocomotionActionAnalyzer: [
LocomotionActionAbsoluteRender,
LocomotionActionRelativeRender,
LocomotionActionRatioRender, ],
LogEntryCountAnalyzer: [
JSONRender,
],
SimulationRoundsAnalyzer: [
JSONRender,
SimulationRoundsRender,
]
}
def get_renderer(cls: type) -> [type]:
if cls not in __MAPPING__:
return [__FALLBACK__]
return __MAPPING__[cls]
def render(cls: type, results: List[Result]):
for r in get_renderer(cls):
p = r()
p.result_types.append(cls)
p.render(results)