4193 def testModifier(self):
4195 Process._firstProcess =
True 4197 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4199 Process._firstProcess =
True 4201 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4204 m1.toModify(p.a,_mod_fred)
4205 self.assertEqual(p.a.fred.value(),2)
4206 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4207 m1.toModify(p.b, wilma = 2)
4208 self.assertEqual(p.b.wilma.value(),2)
4209 self.assertTrue(p.isUsingModifier(m1))
4212 Process._firstProcess =
True 4214 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4215 m1.toModify(p.a,_mod_fred)
4216 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4217 m1.toModify(p.b, wilma = 2)
4218 self.assertEqual(p.a.fred.value(),1)
4219 self.assertEqual(p.b.wilma.value(),1)
4220 self.assertEqual(p.isUsingModifier(m1),
False)
4223 Process._firstProcess =
True 4225 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4226 m1.toModify(p.a, fred = int32(2))
4227 p.b = p.a.clone(wilma = int32(3))
4228 self.assertEqual(p.a.fred.value(),2)
4229 self.assertEqual(p.a.wilma.value(),1)
4230 self.assertEqual(p.b.fred.value(),2)
4231 self.assertEqual(p.b.wilma.value(),3)
4234 Process._firstProcess =
True 4236 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones =
PSet(fred = int32(1)))
4237 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4238 self.assertEqual(hasattr(p.a,
"fred"),
False)
4239 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4240 self.assertEqual(p.a.wilma.value(),1)
4243 Process._firstProcess =
True 4245 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4246 m1.toModify(p.a, wilma = int32(2))
4247 self.assertEqual(p.a.fred.value(), 1)
4248 self.assertEqual(p.a.wilma.value(),2)
4251 Process._firstProcess =
True 4253 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
PSet(fred = int32(1), wilma = int32(1)))
4254 m1.toModify(p.a, flintstones = dict(fred = int32(2)))
4255 self.assertEqual(p.a.flintstones.fred.value(),2)
4256 self.assertEqual(p.a.flintstones.wilma.value(),1)
4259 Process._firstProcess =
True 4261 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
PSet(fred =
PSet(wilma = int32(1))))
4262 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4263 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4266 Process._firstProcess =
True 4268 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(
PSet(fred = int32(1)),
PSet(wilma = int32(1))))
4269 m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
4270 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4271 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4274 Process._firstProcess =
True 4276 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4277 m1.toModify(p.a, fred = {1:7})
4278 self.assertEqual(p.a.fred[0],1)
4279 self.assertEqual(p.a.fred[1],7)
4280 self.assertEqual(p.a.fred[2],3)
4283 Process._firstProcess =
True 4285 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4287 try: m1.toModify(p.a, fred = {5:7})
4288 except IndexError
as e: raised =
True 4289 self.assertEqual(raised,
True)
4292 Process._firstProcess =
True 4294 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(
PSet(fred = int32(1)),
PSet(wilma = int32(1))))
4296 try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
4297 except TypeError
as e: raised =
True 4298 self.assertEqual(raised,
True)
4302 class ProcModifierMod(
object):
4304 self.proc_mod_ = modifier.makeProcessModifier(func)
4307 self.a = EDAnalyzer(
"Dummy")
4308 testMod = DummyMod()
4310 self.assertTrue(hasattr(p,
"a"))
4312 Process._firstProcess =
True 4314 testProcMod = ProcModifierMod(m1,_rem_a)
4316 p.extend(testProcMod)
4317 self.assertTrue(
not hasattr(p,
"a"))
4320 mc = ModifierChain(m1)
4321 Process._firstProcess =
True 4323 self.assertTrue(p.isUsingModifier(m1))
4324 self.assertTrue(p.isUsingModifier(mc))
4325 testMod = DummyMod()
4326 p.b = EDAnalyzer(
"Dummy2", fred = int32(1))
4327 m1.toModify(p.b, fred = int32(3))
4329 testProcMod = ProcModifierMod(m1,_rem_a)
4330 p.extend(testProcMod)
4331 self.assertTrue(
not hasattr(p,
"a"))
4332 self.assertEqual(p.b.fred.value(),3)
4336 mc = ModifierChain(m1,m2)
4337 mclone = mc.copyAndExclude([m2])
4338 self.assertTrue(
not mclone._isOrContains(m2))
4339 self.assertTrue(mclone._isOrContains(m1))
4341 mc2 = ModifierChain(mc,m3)
4342 mclone = mc2.copyAndExclude([m2])
4343 self.assertTrue(
not mclone._isOrContains(m2))
4344 self.assertTrue(mclone._isOrContains(m1))
4345 self.assertTrue(mclone._isOrContains(m3))
4349 Process._firstProcess =
True 4351 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4352 (m1 & m2).toModify(p.a, fred = int32(2))
4353 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4354 self.assertEqual(p.a.fred, 1)
4357 Process._firstProcess =
True 4359 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4360 (m1 & m2).toModify(p.a, fred = int32(2))
4361 self.assertEqual(p.a.fred, 2)
4365 Process._firstProcess =
True 4367 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4368 (m1 & m2 & m3).toModify(p.a, fred = int32(2))
4369 self.assertEqual(p.a.fred, 2)
4370 (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
4371 self.assertEqual(p.a.fred, 3)
4372 ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
4373 self.assertEqual(p.a.fred, 4)
4377 Process._firstProcess =
True 4379 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4380 (~m1).toModify(p.a, fred=2)
4381 self.assertEqual(p.a.fred, 1)
4382 (~m2).toModify(p.a, wilma=2)
4383 self.assertEqual(p.a.wilma, 2)
4384 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4385 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4390 Process._firstProcess =
True 4392 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4393 (m1 | m2).toModify(p.a, fred=2)
4394 self.assertEqual(p.a.fred, 2)
4395 (m1 | m2 | m3).toModify(p.a, fred=3)
4396 self.assertEqual(p.a.fred, 3)
4397 (m3 | m2 | m1).toModify(p.a, fred=4)
4398 self.assertEqual(p.a.fred, 4)
4399 ((m1 | m2) | m3).toModify(p.a, fred=5)
4400 self.assertEqual(p.a.fred, 5)
4401 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4402 self.assertEqual(p.a.fred, 6)
4403 (m2 | m3).toModify(p.a, fred=7)
4404 self.assertEqual(p.a.fred, 6)
4405 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4406 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4412 Process._firstProcess =
True 4414 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4415 (m1 & ~m2).toModify(p.a, fred=2)
4416 self.assertEqual(p.a.fred, 1)
4417 (m1 & ~m3).toModify(p.a, fred=2)
4418 self.assertEqual(p.a.fred, 2)
4419 (m1 | ~m2).toModify(p.a, fred=3)
4420 self.assertEqual(p.a.fred, 3)
4421 (~m1 | ~m2).toModify(p.a, fred=4)
4422 self.assertEqual(p.a.fred, 3)
4423 (~m3 & ~m4).toModify(p.a, fred=4)
4424 self.assertEqual(p.a.fred, 4)
4425 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4426 self.assertEqual(p.a.fred, 5)
4429 Process._firstProcess =
True 4431 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4432 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4433 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a, EDProducer(
"YourProducer")))
4435 p.b =EDAnalyzer(
"BAn")
4436 p.c =EDProducer(
"c")
4437 p.d =EDProducer(
"d")
4441 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4442 self.assertEqual(p.a.wilma.value(),3)
4443 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4444 self.assertEqual(hasattr(p,
"fred"),
False)
4445 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4446 p.e =EDProducer(
"e")
4447 m1.toReplaceWith(p.td, Task(p.e))
4448 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4450 p.b =EDAnalyzer(
"BAn")
4451 p.c =EDProducer(
"c")
4452 p.d =EDProducer(
"d")
4455 p.tc = ConditionalTask(p.c)
4456 p.td = ConditionalTask(p.d)
4458 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4459 self.assertEqual(p.a.wilma.value(),3)
4460 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4461 self.assertEqual(hasattr(p,
"fred"),
False)
4462 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4463 p.e =EDProducer(
"e")
4464 m1.toReplaceWith(p.td, ConditionalTask(p.e))
4465 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4468 Process._firstProcess =
True 4470 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4471 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4472 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4478 Process._firstProcess =
True 4480 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4481 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4482 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4483 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4484 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4485 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4486 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4487 (m1 & m2).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer1"))
4488 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4489 (m1 & m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4490 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4491 (~m1).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4492 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4493 (~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4494 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4495 (m1 | m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer3"))
4496 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4497 (m3 | m4).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer4"))
4498 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4503 Process._firstProcess =
True 4505 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4506 p.b = EDProducer(
"MyProducer", barney = int32(1), betty = int32(1))
4507 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4508 self.assertEqual(p.a.fred, 2)
4509 self.assertEqual(p.a.wilma, 1)
4510 self.assertEqual(p.b.barney, 1)
4511 self.assertEqual(p.b.betty, 3)
4512 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4513 self.assertEqual(p.a.fred, 2)
4514 self.assertEqual(p.a.wilma, 4)
4515 self.assertEqual(p.b.barney, 5)
4516 self.assertEqual(p.b.betty, 3)
4517 (m2 & ~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4518 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4519 self.assertEqual(p.b.barney, 6)
4520 self.assertEqual(p.b.betty, 3)
4521 (m1 & ~m3).toModify(p.a, param=int32(42)).toReplaceWith(p.b, EDProducer(
"YourProducer"))
4522 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4523 self.assertEqual(p.a.param, 42)
4524 self.assertEqual(p.b.type_(),
"YourProducer")
4531 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4532 self.assertEqual(a.foo2[0].type,
"Foo3")
4535 self.assertEqual(a.foo2[0].type,
"Foo3")
4536 self.assertEqual(a.foo4[0].type,
"Foo4")
4538 m.toModify(a, foo2 =
None)
4539 self.assertFalse(hasattr(a,
"foo2"))
4540 self.assertEqual(a.foo4[0].type,
"Foo4")
4543 self.assertFalse(hasattr(a,
"foo2"))
4544 self.assertFalse(hasattr(a,
"foo4"))
4545 self.assertTrue(hasattr(a,
"bar"))
4546 self.assertEqual(a.bar[0].type,
"Bar")
4549 sp = SwitchProducerTest(test1 = EDProducer(
"Foo",
4551 b =
PSet(c = int32(2))),
4552 test2 = EDProducer(
"Bar",
4554 bb =
PSet(cc = int32(12))))
4559 test1 = dict(a = 4, b = dict(c =
None)),
4560 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4561 self.assertEqual(sp.test1.a.value(), 4)
4562 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4563 self.assertEqual(sp.test2.aa.value(), 15)
4564 self.assertEqual(sp.test2.bb.cc.value(), 45)
4565 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4567 m.toReplaceWith(sp.test1, EDProducer(
"Fred", x = int32(42)))
4568 self.assertEqual(sp.test1.type_(),
"Fred")
4569 self.assertEqual(sp.test1.x.value(), 42)
4570 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1, EDAnalyzer(
"Foo")))
4572 m.toModify(sp, test2 = EDProducer(
"Xyzzy", x = int32(24)))
4573 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4574 self.assertEqual(sp.test2.x.value(), 24)
4575 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 = EDAnalyzer(
"Foo")))
4577 m.toModify(sp, test3 = EDProducer(
"Wilma", y = int32(24)))
4578 self.assertEqual(sp.test3.type_(),
"Wilma")
4579 self.assertEqual(sp.test3.y.value(), 24)
4580 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 = EDAnalyzer(
"Foo")))
4582 m.toModify(sp, test2 =
None)
4583 self.assertEqual(hasattr(sp,
"test2"),
False)
4585 m.toModify(sp, test2 = EDAlias(foo =
VPSet(
PSet(type =
string(
"int")))))
4586 self.assertTrue(hasattr(sp.test2,
"foo"))
4588 m.toReplaceWith(sp.test2, EDAlias(bar =
VPSet(
PSet(type =
string(
"int")))))
4589 self.assertTrue(hasattr(sp.test2,
"bar"))
4591 m.toModify(sp, test2 = EDAlias(xyzzy =
VPSet(
PSet(type =
string(
"int")))))
4592 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4594 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2, EDProducer(
"Foo")))
4595 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)