def testInheritatedMethods(self): ph1 = PolarizedPhoton(8000.0, Vector(2, 4, 5), StokesVector([1, 2, 3, 4])) ph1.setUnitDirectionVector(Vector(1, 0, 0)) ph1.setEnergy(9000) self.assertTrue(ph1.unitDirectionVector().components()[0] == 1) self.assertTrue(ph1.unitDirectionVector().components()[1] == 0) self.assertTrue(ph1.unitDirectionVector().components()[2] == 0) self.assertTrue(ph1.energy() == 9000.0)
def testDuplicate(self): ph1 = PolarizedPhoton(8000.0, Vector(2, 4, 5), StokesVector([1, 2, 3, 4])) ph2 = ph1.duplicate() assert_array_almost_equal(ph1.stokesVector().components(), ph2.stokesVector().components()) assert_array_almost_equal(ph1.unitDirectionVector().components(), ph2.unitDirectionVector().components())
def testConstructor(self): photon = PolarizedPhoton(energy_in_ev=8000, direction_vector=Vector(0.0, 1.0, 0.0), stokes_vector=StokesVector( [1.0, 0.0, 1.0, 0.0])) self.assertIsInstance(photon, PolarizedPhoton) self.assertTrue(photon.unitDirectionVector() == Vector(0.0, 1.0, 0.0)) self.assertTrue( photon.stokesVector() == StokesVector([1.0, 0.0, 1.0, 0.0]))