forked from acts-project/acts
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_algorithms.py
More file actions
112 lines (92 loc) · 3.06 KB
/
test_algorithms.py
File metadata and controls
112 lines (92 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import pytest
import acts
from acts.examples import (
AdaptiveMultiVertexFinderAlgorithm,
VertexFitterAlgorithm,
IterativeVertexFinderAlgorithm,
HoughVertexFinderAlgorithm,
SpacePointMaker,
TrackFindingAlgorithm,
GridTripletSeedingAlgorithm,
OrthogonalTripletSeedingAlgorithm,
TrackParamsEstimationAlgorithm,
EventGenerator,
FatrasSimulation,
MaterialMapping,
TruthTrackFinder,
ParticleSelector,
TruthVertexFinder,
TrackParameterSmearing,
TrackSelectorAlgorithm,
TrackFittingAlgorithm,
ParticlesPrinter,
TrackParametersPrinter,
PropagationAlgorithm,
DigitizationAlgorithm,
HelloLoggerAlgorithm,
HelloRandomAlgorithm,
HelloWhiteBoardAlgorithm,
)
from helpers import geant4Enabled, hepmc3Enabled
@pytest.mark.parametrize(
"alg",
[
AdaptiveMultiVertexFinderAlgorithm,
VertexFitterAlgorithm,
IterativeVertexFinderAlgorithm,
HoughVertexFinderAlgorithm,
SpacePointMaker,
TrackFindingAlgorithm,
GridTripletSeedingAlgorithm,
OrthogonalTripletSeedingAlgorithm,
TrackParamsEstimationAlgorithm,
EventGenerator,
FatrasSimulation,
MaterialMapping,
TruthTrackFinder,
ParticleSelector,
TruthVertexFinder,
TrackParameterSmearing,
TrackSelectorAlgorithm,
TrackFittingAlgorithm,
ParticlesPrinter,
TrackParametersPrinter,
PropagationAlgorithm,
HelloRandomAlgorithm,
HelloWhiteBoardAlgorithm,
# GeantinoRecording,
# EventRecording,
],
)
def test_algorithm_interface(alg):
assert hasattr(alg, "Config")
@pytest.mark.skipif(not geant4Enabled, reason="Geant4 not set up")
def test_g4_algorithms():
from acts.examples.geant4 import Geant4Simulation
assert hasattr(Geant4Simulation, "Config")
def test_special_algorithm_interfaces():
# just assert they exists
assert DigitizationAlgorithm
assert HelloLoggerAlgorithm
def test_ialgorithm_init_with_log_level():
"""PyIAlgorithm subclass can be initialized with name and log level only."""
class AlgWithLevel(acts.examples.IAlgorithm):
def __init__(self):
super().__init__(name="AlgWithLevel", level=acts.logging.DEBUG)
def execute(self, context):
return acts.examples.ProcessCode.SUCCESS
alg = AlgWithLevel()
assert alg.name() == "AlgWithLevel"
assert alg.logger.level == acts.logging.DEBUG
def test_ialgorithm_init_with_logger():
"""PyIAlgorithm subclass can be initialized with name and a full logger object."""
class AlgWithLogger(acts.examples.IAlgorithm):
def __init__(self):
logger = acts.getDefaultLogger("AlgWithLogger", acts.logging.VERBOSE)
super().__init__(name="AlgWithLogger", logger=logger)
def execute(self, context):
return acts.examples.ProcessCode.SUCCESS
alg = AlgWithLogger()
assert alg.name() == "AlgWithLogger"
assert alg.logger.level == acts.logging.VERBOSE
assert alg.logger.name == "AlgWithLogger"