4212 def testModifier(self):
4214 Process._firstProcess =
True 4216 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4218 Process._firstProcess =
True 4220 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4223 m1.toModify(p.a,_mod_fred)
4224 self.assertEqual(p.a.fred.value(),2)
4225 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4226 m1.toModify(p.b, wilma = 2)
4227 self.assertEqual(p.b.wilma.value(),2)
4228 self.assertTrue(p.isUsingModifier(m1))
4231 Process._firstProcess =
True 4233 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4234 m1.toModify(p.a,_mod_fred)
4235 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4236 m1.toModify(p.b, wilma = 2)
4237 self.assertEqual(p.a.fred.value(),1)
4238 self.assertEqual(p.b.wilma.value(),1)
4239 self.assertEqual(p.isUsingModifier(m1),
False)
4242 Process._firstProcess =
True 4244 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4245 m1.toModify(p.a, fred = int32(2))
4246 p.b = p.a.clone(wilma = int32(3))
4247 self.assertEqual(p.a.fred.value(),2)
4248 self.assertEqual(p.a.wilma.value(),1)
4249 self.assertEqual(p.b.fred.value(),2)
4250 self.assertEqual(p.b.wilma.value(),3)
4253 Process._firstProcess =
True 4255 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones =
PSet(fred = int32(1)))
4256 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4257 self.assertEqual(hasattr(p.a,
"fred"),
False)
4258 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4259 self.assertEqual(p.a.wilma.value(),1)
4262 Process._firstProcess =
True 4264 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4265 m1.toModify(p.a, wilma = int32(2))
4266 self.assertEqual(p.a.fred.value(), 1)
4267 self.assertEqual(p.a.wilma.value(),2)
4270 Process._firstProcess =
True 4272 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
PSet(fred = int32(1), wilma = int32(1)))
4273 m1.toModify(p.a, flintstones = dict(fred = int32(2)))
4274 self.assertEqual(p.a.flintstones.fred.value(),2)
4275 self.assertEqual(p.a.flintstones.wilma.value(),1)
4278 Process._firstProcess =
True 4280 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
PSet(fred =
PSet(wilma = int32(1))))
4281 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4282 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4285 Process._firstProcess =
True 4287 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(
PSet(fred = int32(1)),
PSet(wilma = int32(1))))
4288 m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
4289 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4290 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4293 Process._firstProcess =
True 4295 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4296 m1.toModify(p.a, fred = {1:7})
4297 self.assertEqual(p.a.fred[0],1)
4298 self.assertEqual(p.a.fred[1],7)
4299 self.assertEqual(p.a.fred[2],3)
4302 Process._firstProcess =
True 4304 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4306 try: m1.toModify(p.a, fred = {5:7})
4307 except IndexError
as e: raised =
True 4308 self.assertEqual(raised,
True)
4311 Process._firstProcess =
True 4313 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(
PSet(fred = int32(1)),
PSet(wilma = int32(1))))
4315 try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
4316 except TypeError
as e: raised =
True 4317 self.assertEqual(raised,
True)
4321 class ProcModifierMod(
object):
4323 self.proc_mod_ = modifier.makeProcessModifier(func)
4326 self.a = EDAnalyzer(
"Dummy")
4327 testMod = DummyMod()
4329 self.assertTrue(hasattr(p,
"a"))
4331 Process._firstProcess =
True 4333 testProcMod = ProcModifierMod(m1,_rem_a)
4335 p.extend(testProcMod)
4336 self.assertTrue(
not hasattr(p,
"a"))
4339 mc = ModifierChain(m1)
4340 Process._firstProcess =
True 4342 self.assertTrue(p.isUsingModifier(m1))
4343 self.assertTrue(p.isUsingModifier(mc))
4344 testMod = DummyMod()
4345 p.b = EDAnalyzer(
"Dummy2", fred = int32(1))
4346 m1.toModify(p.b, fred = int32(3))
4348 testProcMod = ProcModifierMod(m1,_rem_a)
4349 p.extend(testProcMod)
4350 self.assertTrue(
not hasattr(p,
"a"))
4351 self.assertEqual(p.b.fred.value(),3)
4355 mc = ModifierChain(m1,m2)
4356 mclone = mc.copyAndExclude([m2])
4357 self.assertTrue(
not mclone._isOrContains(m2))
4358 self.assertTrue(mclone._isOrContains(m1))
4360 mc2 = ModifierChain(mc,m3)
4361 mclone = mc2.copyAndExclude([m2])
4362 self.assertTrue(
not mclone._isOrContains(m2))
4363 self.assertTrue(mclone._isOrContains(m1))
4364 self.assertTrue(mclone._isOrContains(m3))
4368 Process._firstProcess =
True 4370 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4371 (m1 & m2).toModify(p.a, fred = int32(2))
4372 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4373 self.assertEqual(p.a.fred, 1)
4376 Process._firstProcess =
True 4378 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4379 (m1 & m2).toModify(p.a, fred = int32(2))
4380 self.assertEqual(p.a.fred, 2)
4384 Process._firstProcess =
True 4386 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4387 (m1 & m2 & m3).toModify(p.a, fred = int32(2))
4388 self.assertEqual(p.a.fred, 2)
4389 (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
4390 self.assertEqual(p.a.fred, 3)
4391 ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
4392 self.assertEqual(p.a.fred, 4)
4396 Process._firstProcess =
True 4398 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4399 (~m1).toModify(p.a, fred=2)
4400 self.assertEqual(p.a.fred, 1)
4401 (~m2).toModify(p.a, wilma=2)
4402 self.assertEqual(p.a.wilma, 2)
4403 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4404 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4409 Process._firstProcess =
True 4411 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4412 (m1 | m2).toModify(p.a, fred=2)
4413 self.assertEqual(p.a.fred, 2)
4414 (m1 | m2 | m3).toModify(p.a, fred=3)
4415 self.assertEqual(p.a.fred, 3)
4416 (m3 | m2 | m1).toModify(p.a, fred=4)
4417 self.assertEqual(p.a.fred, 4)
4418 ((m1 | m2) | m3).toModify(p.a, fred=5)
4419 self.assertEqual(p.a.fred, 5)
4420 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4421 self.assertEqual(p.a.fred, 6)
4422 (m2 | m3).toModify(p.a, fred=7)
4423 self.assertEqual(p.a.fred, 6)
4424 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4425 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4431 Process._firstProcess =
True 4433 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4434 (m1 & ~m2).toModify(p.a, fred=2)
4435 self.assertEqual(p.a.fred, 1)
4436 (m1 & ~m3).toModify(p.a, fred=2)
4437 self.assertEqual(p.a.fred, 2)
4438 (m1 | ~m2).toModify(p.a, fred=3)
4439 self.assertEqual(p.a.fred, 3)
4440 (~m1 | ~m2).toModify(p.a, fred=4)
4441 self.assertEqual(p.a.fred, 3)
4442 (~m3 & ~m4).toModify(p.a, fred=4)
4443 self.assertEqual(p.a.fred, 4)
4444 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4445 self.assertEqual(p.a.fred, 5)
4448 Process._firstProcess =
True 4450 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4451 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4452 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a, EDProducer(
"YourProducer")))
4454 p.b =EDAnalyzer(
"BAn")
4455 p.c =EDProducer(
"c")
4456 p.d =EDProducer(
"d")
4460 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4461 self.assertEqual(p.a.wilma.value(),3)
4462 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4463 self.assertEqual(hasattr(p,
"fred"),
False)
4464 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4465 p.e =EDProducer(
"e")
4466 m1.toReplaceWith(p.td, Task(p.e))
4467 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4469 p.b =EDAnalyzer(
"BAn")
4470 p.c =EDProducer(
"c")
4471 p.d =EDProducer(
"d")
4474 p.tc = ConditionalTask(p.c)
4475 p.td = ConditionalTask(p.d)
4477 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4478 self.assertEqual(p.a.wilma.value(),3)
4479 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4480 self.assertEqual(hasattr(p,
"fred"),
False)
4481 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4482 p.e =EDProducer(
"e")
4483 m1.toReplaceWith(p.td, ConditionalTask(p.e))
4484 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4487 Process._firstProcess =
True 4489 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4490 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4491 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4497 Process._firstProcess =
True 4499 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4500 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4501 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4502 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4503 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4504 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4505 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4506 (m1 & m2).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer1"))
4507 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4508 (m1 & m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4509 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4510 (~m1).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4511 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4512 (~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4513 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4514 (m1 | m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer3"))
4515 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4516 (m3 | m4).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer4"))
4517 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4522 Process._firstProcess =
True 4524 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4525 p.b = EDProducer(
"MyProducer", barney = int32(1), betty = int32(1))
4526 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4527 self.assertEqual(p.a.fred, 2)
4528 self.assertEqual(p.a.wilma, 1)
4529 self.assertEqual(p.b.barney, 1)
4530 self.assertEqual(p.b.betty, 3)
4531 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4532 self.assertEqual(p.a.fred, 2)
4533 self.assertEqual(p.a.wilma, 4)
4534 self.assertEqual(p.b.barney, 5)
4535 self.assertEqual(p.b.betty, 3)
4536 (m2 & ~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4537 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4538 self.assertEqual(p.b.barney, 6)
4539 self.assertEqual(p.b.betty, 3)
4540 (m1 & ~m3).toModify(p.a, param=int32(42)).toReplaceWith(p.b, EDProducer(
"YourProducer"))
4541 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4542 self.assertEqual(p.a.param, 42)
4543 self.assertEqual(p.b.type_(),
"YourProducer")
4550 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4551 self.assertEqual(a.foo2[0].type,
"Foo3")
4554 self.assertEqual(a.foo2[0].type,
"Foo3")
4555 self.assertEqual(a.foo4[0].type,
"Foo4")
4557 m.toModify(a, foo2 =
None)
4558 self.assertFalse(hasattr(a,
"foo2"))
4559 self.assertEqual(a.foo4[0].type,
"Foo4")
4562 self.assertFalse(hasattr(a,
"foo2"))
4563 self.assertFalse(hasattr(a,
"foo4"))
4564 self.assertTrue(hasattr(a,
"bar"))
4565 self.assertEqual(a.bar[0].type,
"Bar")
4568 sp = SwitchProducerTest(test1 = EDProducer(
"Foo",
4570 b =
PSet(c = int32(2))),
4571 test2 = EDProducer(
"Bar",
4573 bb =
PSet(cc = int32(12))))
4578 test1 = dict(a = 4, b = dict(c =
None)),
4579 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4580 self.assertEqual(sp.test1.a.value(), 4)
4581 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4582 self.assertEqual(sp.test2.aa.value(), 15)
4583 self.assertEqual(sp.test2.bb.cc.value(), 45)
4584 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4586 m.toReplaceWith(sp.test1, EDProducer(
"Fred", x = int32(42)))
4587 self.assertEqual(sp.test1.type_(),
"Fred")
4588 self.assertEqual(sp.test1.x.value(), 42)
4589 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1, EDAnalyzer(
"Foo")))
4591 m.toModify(sp, test2 = EDProducer(
"Xyzzy", x = int32(24)))
4592 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4593 self.assertEqual(sp.test2.x.value(), 24)
4594 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 = EDAnalyzer(
"Foo")))
4596 m.toModify(sp, test3 = EDProducer(
"Wilma", y = int32(24)))
4597 self.assertEqual(sp.test3.type_(),
"Wilma")
4598 self.assertEqual(sp.test3.y.value(), 24)
4599 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 = EDAnalyzer(
"Foo")))
4601 m.toModify(sp, test2 =
None)
4602 self.assertEqual(hasattr(sp,
"test2"),
False)
4604 m.toModify(sp, test2 = EDAlias(foo =
VPSet(
PSet(type =
string(
"int")))))
4605 self.assertTrue(hasattr(sp.test2,
"foo"))
4607 m.toReplaceWith(sp.test2, EDAlias(bar =
VPSet(
PSet(type =
string(
"int")))))
4608 self.assertTrue(hasattr(sp.test2,
"bar"))
4610 m.toModify(sp, test2 = EDAlias(xyzzy =
VPSet(
PSet(type =
string(
"int")))))
4611 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4613 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2, EDProducer(
"Foo")))
4614 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)