4214 def testModifier(self):
4216 Process._firstProcess =
True 4218 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4220 Process._firstProcess =
True 4222 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4225 m1.toModify(p.a,_mod_fred)
4226 self.assertEqual(p.a.fred.value(),2)
4227 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4228 m1.toModify(p.b, wilma = 2)
4229 self.assertEqual(p.b.wilma.value(),2)
4230 self.assertTrue(p.isUsingModifier(m1))
4233 Process._firstProcess =
True 4235 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4236 m1.toModify(p.a,_mod_fred)
4237 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4238 m1.toModify(p.b, wilma = 2)
4239 self.assertEqual(p.a.fred.value(),1)
4240 self.assertEqual(p.b.wilma.value(),1)
4241 self.assertEqual(p.isUsingModifier(m1),
False)
4244 Process._firstProcess =
True 4246 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4247 m1.toModify(p.a, fred = int32(2))
4248 p.b = p.a.clone(wilma = int32(3))
4249 self.assertEqual(p.a.fred.value(),2)
4250 self.assertEqual(p.a.wilma.value(),1)
4251 self.assertEqual(p.b.fred.value(),2)
4252 self.assertEqual(p.b.wilma.value(),3)
4255 Process._firstProcess =
True 4257 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones =
PSet(fred = int32(1)))
4258 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4259 self.assertEqual(hasattr(p.a,
"fred"),
False)
4260 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4261 self.assertEqual(p.a.wilma.value(),1)
4264 Process._firstProcess =
True 4266 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4267 m1.toModify(p.a, wilma = int32(2))
4268 self.assertEqual(p.a.fred.value(), 1)
4269 self.assertEqual(p.a.wilma.value(),2)
4272 Process._firstProcess =
True 4274 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
PSet(fred = int32(1), wilma = int32(1)))
4275 m1.toModify(p.a, flintstones = dict(fred = int32(2)))
4276 self.assertEqual(p.a.flintstones.fred.value(),2)
4277 self.assertEqual(p.a.flintstones.wilma.value(),1)
4280 Process._firstProcess =
True 4282 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
PSet(fred =
PSet(wilma = int32(1))))
4283 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4284 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4287 Process._firstProcess =
True 4289 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(
PSet(fred = int32(1)),
PSet(wilma = int32(1))))
4290 m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
4291 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4292 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4295 Process._firstProcess =
True 4297 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4298 m1.toModify(p.a, fred = {1:7})
4299 self.assertEqual(p.a.fred[0],1)
4300 self.assertEqual(p.a.fred[1],7)
4301 self.assertEqual(p.a.fred[2],3)
4304 Process._firstProcess =
True 4306 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4308 try: m1.toModify(p.a, fred = {5:7})
4309 except IndexError
as e: raised =
True 4310 self.assertEqual(raised,
True)
4313 Process._firstProcess =
True 4315 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(
PSet(fred = int32(1)),
PSet(wilma = int32(1))))
4317 try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
4318 except TypeError
as e: raised =
True 4319 self.assertEqual(raised,
True)
4323 class ProcModifierMod(
object):
4325 self.proc_mod_ = modifier.makeProcessModifier(func)
4328 self.a = EDAnalyzer(
"Dummy")
4329 testMod = DummyMod()
4331 self.assertTrue(hasattr(p,
"a"))
4333 Process._firstProcess =
True 4335 testProcMod = ProcModifierMod(m1,_rem_a)
4337 p.extend(testProcMod)
4338 self.assertTrue(
not hasattr(p,
"a"))
4341 mc = ModifierChain(m1)
4342 Process._firstProcess =
True 4344 self.assertTrue(p.isUsingModifier(m1))
4345 self.assertTrue(p.isUsingModifier(mc))
4346 testMod = DummyMod()
4347 p.b = EDAnalyzer(
"Dummy2", fred = int32(1))
4348 m1.toModify(p.b, fred = int32(3))
4350 testProcMod = ProcModifierMod(m1,_rem_a)
4351 p.extend(testProcMod)
4352 self.assertTrue(
not hasattr(p,
"a"))
4353 self.assertEqual(p.b.fred.value(),3)
4357 mc = ModifierChain(m1,m2)
4358 mclone = mc.copyAndExclude([m2])
4359 self.assertTrue(
not mclone._isOrContains(m2))
4360 self.assertTrue(mclone._isOrContains(m1))
4362 mc2 = ModifierChain(mc,m3)
4363 mclone = mc2.copyAndExclude([m2])
4364 self.assertTrue(
not mclone._isOrContains(m2))
4365 self.assertTrue(mclone._isOrContains(m1))
4366 self.assertTrue(mclone._isOrContains(m3))
4370 Process._firstProcess =
True 4372 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4373 (m1 & m2).toModify(p.a, fred = int32(2))
4374 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4375 self.assertEqual(p.a.fred, 1)
4378 Process._firstProcess =
True 4380 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4381 (m1 & m2).toModify(p.a, fred = int32(2))
4382 self.assertEqual(p.a.fred, 2)
4386 Process._firstProcess =
True 4388 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4389 (m1 & m2 & m3).toModify(p.a, fred = int32(2))
4390 self.assertEqual(p.a.fred, 2)
4391 (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
4392 self.assertEqual(p.a.fred, 3)
4393 ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
4394 self.assertEqual(p.a.fred, 4)
4398 Process._firstProcess =
True 4400 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4401 (~m1).toModify(p.a, fred=2)
4402 self.assertEqual(p.a.fred, 1)
4403 (~m2).toModify(p.a, wilma=2)
4404 self.assertEqual(p.a.wilma, 2)
4405 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4406 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4411 Process._firstProcess =
True 4413 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4414 (m1 | m2).toModify(p.a, fred=2)
4415 self.assertEqual(p.a.fred, 2)
4416 (m1 | m2 | m3).toModify(p.a, fred=3)
4417 self.assertEqual(p.a.fred, 3)
4418 (m3 | m2 | m1).toModify(p.a, fred=4)
4419 self.assertEqual(p.a.fred, 4)
4420 ((m1 | m2) | m3).toModify(p.a, fred=5)
4421 self.assertEqual(p.a.fred, 5)
4422 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4423 self.assertEqual(p.a.fred, 6)
4424 (m2 | m3).toModify(p.a, fred=7)
4425 self.assertEqual(p.a.fred, 6)
4426 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4427 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4433 Process._firstProcess =
True 4435 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4436 (m1 & ~m2).toModify(p.a, fred=2)
4437 self.assertEqual(p.a.fred, 1)
4438 (m1 & ~m3).toModify(p.a, fred=2)
4439 self.assertEqual(p.a.fred, 2)
4440 (m1 | ~m2).toModify(p.a, fred=3)
4441 self.assertEqual(p.a.fred, 3)
4442 (~m1 | ~m2).toModify(p.a, fred=4)
4443 self.assertEqual(p.a.fred, 3)
4444 (~m3 & ~m4).toModify(p.a, fred=4)
4445 self.assertEqual(p.a.fred, 4)
4446 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4447 self.assertEqual(p.a.fred, 5)
4450 Process._firstProcess =
True 4452 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4453 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4454 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a, EDProducer(
"YourProducer")))
4456 p.b =EDAnalyzer(
"BAn")
4457 p.c =EDProducer(
"c")
4458 p.d =EDProducer(
"d")
4462 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4463 self.assertEqual(p.a.wilma.value(),3)
4464 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4465 self.assertEqual(hasattr(p,
"fred"),
False)
4466 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4467 p.e =EDProducer(
"e")
4468 m1.toReplaceWith(p.td, Task(p.e))
4469 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4471 p.b =EDAnalyzer(
"BAn")
4472 p.c =EDProducer(
"c")
4473 p.d =EDProducer(
"d")
4476 p.tc = ConditionalTask(p.c)
4477 p.td = ConditionalTask(p.d)
4479 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4480 self.assertEqual(p.a.wilma.value(),3)
4481 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4482 self.assertEqual(hasattr(p,
"fred"),
False)
4483 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4484 p.e =EDProducer(
"e")
4485 m1.toReplaceWith(p.td, ConditionalTask(p.e))
4486 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4489 Process._firstProcess =
True 4491 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4492 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4493 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4499 Process._firstProcess =
True 4501 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4502 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4503 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4504 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4505 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4506 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4507 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4508 (m1 & m2).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer1"))
4509 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4510 (m1 & m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4511 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4512 (~m1).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4513 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4514 (~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4515 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4516 (m1 | m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer3"))
4517 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4518 (m3 | m4).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer4"))
4519 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4524 Process._firstProcess =
True 4526 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4527 p.b = EDProducer(
"MyProducer", barney = int32(1), betty = int32(1))
4528 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4529 self.assertEqual(p.a.fred, 2)
4530 self.assertEqual(p.a.wilma, 1)
4531 self.assertEqual(p.b.barney, 1)
4532 self.assertEqual(p.b.betty, 3)
4533 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4534 self.assertEqual(p.a.fred, 2)
4535 self.assertEqual(p.a.wilma, 4)
4536 self.assertEqual(p.b.barney, 5)
4537 self.assertEqual(p.b.betty, 3)
4538 (m2 & ~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4539 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4540 self.assertEqual(p.b.barney, 6)
4541 self.assertEqual(p.b.betty, 3)
4542 (m1 & ~m3).toModify(p.a, param=int32(42)).toReplaceWith(p.b, EDProducer(
"YourProducer"))
4543 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4544 self.assertEqual(p.a.param, 42)
4545 self.assertEqual(p.b.type_(),
"YourProducer")
4552 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4553 self.assertEqual(a.foo2[0].type,
"Foo3")
4556 self.assertEqual(a.foo2[0].type,
"Foo3")
4557 self.assertEqual(a.foo4[0].type,
"Foo4")
4559 m.toModify(a, foo2 =
None)
4560 self.assertFalse(hasattr(a,
"foo2"))
4561 self.assertEqual(a.foo4[0].type,
"Foo4")
4564 self.assertFalse(hasattr(a,
"foo2"))
4565 self.assertFalse(hasattr(a,
"foo4"))
4566 self.assertTrue(hasattr(a,
"bar"))
4567 self.assertEqual(a.bar[0].type,
"Bar")
4570 sp = SwitchProducerTest(test1 = EDProducer(
"Foo",
4572 b =
PSet(c = int32(2))),
4573 test2 = EDProducer(
"Bar",
4575 bb =
PSet(cc = int32(12))))
4580 test1 = dict(a = 4, b = dict(c =
None)),
4581 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4582 self.assertEqual(sp.test1.a.value(), 4)
4583 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4584 self.assertEqual(sp.test2.aa.value(), 15)
4585 self.assertEqual(sp.test2.bb.cc.value(), 45)
4586 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4588 m.toReplaceWith(sp.test1, EDProducer(
"Fred", x = int32(42)))
4589 self.assertEqual(sp.test1.type_(),
"Fred")
4590 self.assertEqual(sp.test1.x.value(), 42)
4591 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1, EDAnalyzer(
"Foo")))
4593 m.toModify(sp, test2 = EDProducer(
"Xyzzy", x = int32(24)))
4594 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4595 self.assertEqual(sp.test2.x.value(), 24)
4596 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 = EDAnalyzer(
"Foo")))
4598 m.toModify(sp, test3 = EDProducer(
"Wilma", y = int32(24)))
4599 self.assertEqual(sp.test3.type_(),
"Wilma")
4600 self.assertEqual(sp.test3.y.value(), 24)
4601 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 = EDAnalyzer(
"Foo")))
4603 m.toModify(sp, test2 =
None)
4604 self.assertEqual(hasattr(sp,
"test2"),
False)
4606 m.toModify(sp, test2 = EDAlias(foo =
VPSet(
PSet(type =
string(
"int")))))
4607 self.assertTrue(hasattr(sp.test2,
"foo"))
4609 m.toReplaceWith(sp.test2, EDAlias(bar =
VPSet(
PSet(type =
string(
"int")))))
4610 self.assertTrue(hasattr(sp.test2,
"bar"))
4612 m.toModify(sp, test2 = EDAlias(xyzzy =
VPSet(
PSet(type =
string(
"int")))))
4613 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4615 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2, EDProducer(
"Foo")))
4616 m.toModify(sp, test2 = EDProducer(
"Foo"))
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)