Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:14:56

0001 import pytest
0002 
0003 import acts
0004 
0005 import acts.examples
0006 
0007 
0008 def test_version():
0009     assert hasattr(acts, "__version__")
0010     assert hasattr(acts, "version")
0011     assert hasattr(acts.version, "major")
0012     assert hasattr(acts.version, "minor")
0013     assert hasattr(acts.version, "patch")
0014     assert hasattr(acts.version, "commit_hash")
0015     assert hasattr(acts.version, "commit_hash_short")
0016 
0017 
0018 def test_logging():
0019     for l in ("VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL"):
0020         assert hasattr(acts.logging, l)
0021         assert hasattr(acts.logging.Level, l)
0022 
0023 
0024 def test_pgd_particle():
0025     assert len(acts.PdgParticle.__members__) == 19
0026 
0027 
0028 def test_algebra():
0029     v3 = acts.Vector3(1, 2, 3)
0030     with pytest.raises(TypeError):
0031         acts.Vector3(1, 2, 3, 4)
0032     with pytest.raises(TypeError):
0033         acts.Vector3(1, 2)
0034 
0035     v3 = acts.Vector3([1, 2, 3])
0036     with pytest.raises(TypeError):
0037         acts.Vector3([1, 2, 3, 4])
0038     with pytest.raises(TypeError):
0039         acts.Vector3([1, 2])
0040     with pytest.raises(TypeError):
0041         acts.Vector3()
0042 
0043     v4 = acts.Vector4(1, 2, 3, 4)
0044     with pytest.raises(TypeError):
0045         v4 = acts.Vector4(1, 2, 3)
0046     v4 = acts.Vector4([1, 2, 3, 4])
0047     with pytest.raises(TypeError):
0048         acts.Vector4([1, 2, 3])
0049     with pytest.raises(TypeError):
0050         acts.Vector4()
0051 
0052 
0053 def test_empty_sequencer(conf_const):
0054     s = acts.examples.Sequencer()
0055     with pytest.raises(RuntimeError):
0056         s.run()
0057 
0058     s = conf_const(acts.examples.Sequencer, events=1)
0059     s.run()
0060 
0061 
0062 def test_sequencer_single_threaded(ptcl_gun, capfd):
0063     s = acts.examples.Sequencer(numThreads=1, events=2)
0064     ptcl_gun(s)
0065     s.run()
0066     cap = capfd.readouterr()
0067     assert cap.err == ""
0068     assert "Create Sequencer (single-threaded)" in cap.out
0069     assert "Processed 2 events" in cap.out
0070 
0071 
0072 def test_sequencer_multi_threaded(ptcl_gun, capfd):
0073     # This test can use 2 threads (for the 2 events),
0074     # but could be run single-threaded if threading is not available.
0075     s = acts.examples.Sequencer(numThreads=-1, events=2)
0076     ptcl_gun(s)
0077     s.run()
0078     cap = capfd.readouterr()
0079     assert cap.err == ""
0080     assert "Create Sequencer" in cap.out
0081     assert "Processed 2 events" in cap.out
0082 
0083 
0084 def test_random_number():
0085     rnd = acts.examples.RandomNumbers(seed=42)
0086 
0087 
0088 def test_constructors():
0089     s1 = acts.examples.Sequencer()
0090     print(s1)
0091     s2 = acts.examples.Sequencer()
0092     print(s2)