Skip to content

Commit

Permalink
Added test for #165: Segfault extending SourceFeature in python
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasWinchen committed Jan 29, 2018
1 parent e7e5f9e commit dec38b4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/testPythonExtension.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,36 @@ class testCrossLanguagePolymorphism(unittest.TestCase):
obs.process(candidate)
self.assertEqual(i + 1, counter.value)

def test_SourceFeature(self):
Mpc = crp.Mpc
EeV = crp.EeV
nG = crp.nG

class MySourceFeature(crp.SourceFeature):
def __init__(self):
crp.SourceFeature.__init__(self)

def prepareParticle(self, particleState):
particleState.setEnergy(10 * EeV)

vgrid = crp.VectorGrid(crp.Vector3d(0), 128, 1 * Mpc)
crp.initTurbulence(vgrid, 1 * nG, 2 * Mpc, 5 * Mpc, -11. / 3.)
BField = crp.MagneticFieldGrid(vgrid)

m = crp.ModuleList()
m.add(crp.PropagationCK(BField, 1e-4, 0.1 * Mpc, 5 * Mpc))
m.add(crp.MaximumTrajectoryLength(25 * Mpc))

# source setup
source = crp.Source()
source.add(crp.SourcePosition(crp.Vector3d(0, 0, 0) * Mpc))
source.add(crp.SourceIsotropicEmission())
source.add(crp.SourceParticleType(crp.nucleusId(1, 1)))
source.add(MySourceFeature())
m.run(source, 1000)




class testCandidatePropertymap(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit dec38b4

Please sign in to comment.