Best Python code snippet using Testify_python
test_neo_tools.py
Source:test_neo_tools.py
...194class ExtractNeoAttrsTestCase(unittest.TestCase):195 def setUp(self):196 self.maxDiff = None197 self.block = fake_neo('Block', seed=0)198 def assert_dicts_equal(self, d1, d2):199 """Assert that two dictionaries are equal, taking into account arrays.200 Normally, `unittest.TestCase.assertEqual` doesn't work with201 dictionaries containing arrays. This works around that.202 Parameters203 ----------204 d1, d2 : dict205 The dictionaries to compare206 Returns207 -------208 Nothing209 Raises210 ------211 AssertionError : If the `d1` and `d2` are not equal.212 """213 try:214 self.assertEqual(d1, d2)215 except ValueError:216 for (key1, value1), (key2, value2) in zip(sorted(d1.items()),217 sorted(d2.items())):218 self.assertEqual(key1, key2)219 try:220 if hasattr(value1, 'keys') and hasattr(value2, 'keys'):221 self.assert_dicts_equal(value1, value2)222 elif hasattr(value1, 'dtype') and hasattr(value2, 'dtype'):223 assert_array_equal(value1, value2)224 else:225 self.assertEqual(value1, value2)226 except BaseException as exc:227 exc.args += ('key: %s' % key1,)228 raise229 def test__extract_neo_attrs__spiketrain_noarray(self):230 obj = fake_neo('SpikeTrain', seed=0)231 targ = get_fake_values('SpikeTrain', seed=0)232 targ = strip_iter_values(targ)233 res00 = nt.extract_neo_attrs(obj, parents=False, skip_array=True)234 res10 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,235 child_first=True)236 res20 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,237 child_first=False)238 res01 = nt.extract_neo_attrs(obj, parents=True, skip_array=True)239 res11 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,240 child_first=True)241 res21 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,242 child_first=False)243 self.assertEqual(targ, res00)244 self.assertEqual(targ, res10)245 self.assertEqual(targ, res20)246 self.assertEqual(targ, res01)247 self.assertEqual(targ, res11)248 self.assertEqual(targ, res21)249 def test__extract_neo_attrs__spiketrain_noarray_skip_none(self):250 obj = fake_neo('SpikeTrain', seed=0)251 targ = get_fake_values('SpikeTrain', seed=0)252 targ = strip_iter_values(targ)253 for key, value in targ.copy().items():254 if value is None:255 del targ[key]256 res00 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,257 skip_none=True)258 res10 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,259 child_first=True, skip_none=True)260 res20 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,261 child_first=False, skip_none=True)262 res01 = nt.extract_neo_attrs(obj, parents=True, skip_array=True,263 skip_none=True)264 res11 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,265 child_first=True, skip_none=True)266 res21 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,267 child_first=False, skip_none=True)268 self.assertEqual(targ, res00)269 self.assertEqual(targ, res10)270 self.assertEqual(targ, res20)271 self.assertEqual(targ, res01)272 self.assertEqual(targ, res11)273 self.assertEqual(targ, res21)274 def test__extract_neo_attrs__epoch_noarray(self):275 obj = fake_neo('Epoch', seed=0)276 targ = get_fake_values('Epoch', seed=0)277 targ = strip_iter_values(targ)278 res00 = nt.extract_neo_attrs(obj, parents=False, skip_array=True)279 res10 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,280 child_first=True)281 res20 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,282 child_first=False)283 res01 = nt.extract_neo_attrs(obj, parents=True, skip_array=True)284 res11 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,285 child_first=True)286 res21 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,287 child_first=False)288 self.assertEqual(targ, res00)289 self.assertEqual(targ, res10)290 self.assertEqual(targ, res20)291 self.assertEqual(targ, res01)292 self.assertEqual(targ, res11)293 self.assertEqual(targ, res21)294 def test__extract_neo_attrs__event_noarray(self):295 obj = fake_neo('Event', seed=0)296 targ = get_fake_values('Event', seed=0)297 targ = strip_iter_values(targ)298 res00 = nt.extract_neo_attrs(obj, parents=False, skip_array=True)299 res10 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,300 child_first=True)301 res20 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,302 child_first=False)303 res01 = nt.extract_neo_attrs(obj, parents=True, skip_array=True)304 res11 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,305 child_first=True)306 res21 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,307 child_first=False)308 self.assertEqual(targ, res00)309 self.assertEqual(targ, res10)310 self.assertEqual(targ, res20)311 self.assertEqual(targ, res01)312 self.assertEqual(targ, res11)313 self.assertEqual(targ, res21)314 def test__extract_neo_attrs__spiketrain_parents_empty_array(self):315 obj = fake_neo('SpikeTrain', seed=0)316 targ = get_fake_values('SpikeTrain', seed=0)317 del targ['times']318 res000 = nt.extract_neo_attrs(obj, parents=False)319 res100 = nt.extract_neo_attrs(obj, parents=False, child_first=True)320 res200 = nt.extract_neo_attrs(obj, parents=False, child_first=False)321 res010 = nt.extract_neo_attrs(obj, parents=False, skip_array=False)322 res110 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,323 child_first=True)324 res210 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,325 child_first=False)326 res001 = nt.extract_neo_attrs(obj, parents=True)327 res101 = nt.extract_neo_attrs(obj, parents=True, child_first=True)328 res201 = nt.extract_neo_attrs(obj, parents=True, child_first=False)329 res011 = nt.extract_neo_attrs(obj, parents=True, skip_array=False)330 res111 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,331 child_first=True)332 res211 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,333 child_first=False)334 self.assert_dicts_equal(targ, res000)335 self.assert_dicts_equal(targ, res100)336 self.assert_dicts_equal(targ, res200)337 self.assert_dicts_equal(targ, res010)338 self.assert_dicts_equal(targ, res110)339 self.assert_dicts_equal(targ, res210)340 self.assert_dicts_equal(targ, res001)341 self.assert_dicts_equal(targ, res101)342 self.assert_dicts_equal(targ, res201)343 self.assert_dicts_equal(targ, res011)344 self.assert_dicts_equal(targ, res111)345 self.assert_dicts_equal(targ, res211)346 def test__extract_neo_attrs__epoch_parents_empty_array(self):347 obj = fake_neo('Epoch', seed=0)348 targ = get_fake_values('Epoch', seed=0)349 del targ['times']350 res000 = nt.extract_neo_attrs(obj, parents=False)351 res100 = nt.extract_neo_attrs(obj, parents=False, child_first=True)352 res200 = nt.extract_neo_attrs(obj, parents=False, child_first=False)353 res010 = nt.extract_neo_attrs(obj, parents=False, skip_array=False)354 res110 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,355 child_first=True)356 res210 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,357 child_first=False)358 res001 = nt.extract_neo_attrs(obj, parents=True)359 res101 = nt.extract_neo_attrs(obj, parents=True, child_first=True)360 res201 = nt.extract_neo_attrs(obj, parents=True, child_first=False)361 res011 = nt.extract_neo_attrs(obj, parents=True, skip_array=False)362 res111 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,363 child_first=True)364 res211 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,365 child_first=False)366 self.assert_dicts_equal(targ, res000)367 self.assert_dicts_equal(targ, res100)368 self.assert_dicts_equal(targ, res200)369 self.assert_dicts_equal(targ, res010)370 self.assert_dicts_equal(targ, res110)371 self.assert_dicts_equal(targ, res210)372 self.assert_dicts_equal(targ, res001)373 self.assert_dicts_equal(targ, res101)374 self.assert_dicts_equal(targ, res201)375 self.assert_dicts_equal(targ, res011)376 self.assert_dicts_equal(targ, res111)377 self.assert_dicts_equal(targ, res211)378 def test__extract_neo_attrs__event_parents_empty_array(self):379 obj = fake_neo('Event', seed=0)380 targ = get_fake_values('Event', seed=0)381 del targ['times']382 res000 = nt.extract_neo_attrs(obj, parents=False)383 res100 = nt.extract_neo_attrs(obj, parents=False, child_first=True)384 res200 = nt.extract_neo_attrs(obj, parents=False, child_first=False)385 res010 = nt.extract_neo_attrs(obj, parents=False, skip_array=False)386 res110 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,387 child_first=True)388 res210 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,389 child_first=False)390 res001 = nt.extract_neo_attrs(obj, parents=True)391 res101 = nt.extract_neo_attrs(obj, parents=True, child_first=True)392 res201 = nt.extract_neo_attrs(obj, parents=True, child_first=False)393 res011 = nt.extract_neo_attrs(obj, parents=True, skip_array=False)394 res111 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,395 child_first=True)396 res211 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,397 child_first=False)398 self.assert_dicts_equal(targ, res000)399 self.assert_dicts_equal(targ, res100)400 self.assert_dicts_equal(targ, res200)401 self.assert_dicts_equal(targ, res010)402 self.assert_dicts_equal(targ, res110)403 self.assert_dicts_equal(targ, res210)404 self.assert_dicts_equal(targ, res001)405 self.assert_dicts_equal(targ, res101)406 self.assert_dicts_equal(targ, res201)407 self.assert_dicts_equal(targ, res011)408 self.assert_dicts_equal(targ, res111)409 self.assert_dicts_equal(targ, res211)410 def test__extract_neo_attrs__spiketrain_noparents_noarray(self):411 obj = self.block.list_children_by_class('SpikeTrain')[0]412 targ = get_fake_values('SpikeTrain', seed=obj.annotations['seed'])413 targ = strip_iter_values(targ)414 res0 = nt.extract_neo_attrs(obj, parents=False, skip_array=True)415 res1 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,416 child_first=True)417 res2 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,418 child_first=False)419 del res0['i']420 del res1['i']421 del res2['i']422 del res0['j']423 del res1['j']424 del res2['j']425 self.assertEqual(targ, res0)426 self.assertEqual(targ, res1)427 self.assertEqual(targ, res2)428 def test__extract_neo_attrs__epoch_noparents_noarray(self):429 obj = self.block.list_children_by_class('Epoch')[0]430 targ = get_fake_values('Epoch', seed=obj.annotations['seed'])431 targ = strip_iter_values(targ)432 res0 = nt.extract_neo_attrs(obj, parents=False, skip_array=True)433 res1 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,434 child_first=True)435 res2 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,436 child_first=False)437 del res0['i']438 del res1['i']439 del res2['i']440 del res0['j']441 del res1['j']442 del res2['j']443 self.assertEqual(targ, res0)444 self.assertEqual(targ, res1)445 self.assertEqual(targ, res2)446 def test__extract_neo_attrs__event_noparents_noarray(self):447 obj = self.block.list_children_by_class('Event')[0]448 targ = get_fake_values('Event', seed=obj.annotations['seed'])449 targ = strip_iter_values(targ)450 res0 = nt.extract_neo_attrs(obj, parents=False, skip_array=True)451 res1 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,452 child_first=True)453 res2 = nt.extract_neo_attrs(obj, parents=False, skip_array=True,454 child_first=False)455 del res0['i']456 del res1['i']457 del res2['i']458 del res0['j']459 del res1['j']460 del res2['j']461 self.assertEqual(targ, res0)462 self.assertEqual(targ, res1)463 self.assertEqual(targ, res2)464 def test__extract_neo_attrs__spiketrain_noparents_array(self):465 obj = self.block.list_children_by_class('SpikeTrain')[0]466 targ = get_fake_values('SpikeTrain', seed=obj.annotations['seed'])467 del targ['times']468 res00 = nt.extract_neo_attrs(obj, parents=False, skip_array=False)469 res10 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,470 child_first=True)471 res20 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,472 child_first=False)473 res01 = nt.extract_neo_attrs(obj, parents=False)474 res11 = nt.extract_neo_attrs(obj, parents=False, child_first=True)475 res21 = nt.extract_neo_attrs(obj, parents=False, child_first=False)476 del res00['i']477 del res10['i']478 del res20['i']479 del res01['i']480 del res11['i']481 del res21['i']482 del res00['j']483 del res10['j']484 del res20['j']485 del res01['j']486 del res11['j']487 del res21['j']488 self.assert_dicts_equal(targ, res00)489 self.assert_dicts_equal(targ, res10)490 self.assert_dicts_equal(targ, res20)491 self.assert_dicts_equal(targ, res01)492 self.assert_dicts_equal(targ, res11)493 self.assert_dicts_equal(targ, res21)494 def test__extract_neo_attrs__epoch_noparents_array(self):495 obj = self.block.list_children_by_class('Epoch')[0]496 targ = get_fake_values('Epoch', seed=obj.annotations['seed'])497 del targ['times']498 res00 = nt.extract_neo_attrs(obj, parents=False, skip_array=False)499 res10 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,500 child_first=True)501 res20 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,502 child_first=False)503 res01 = nt.extract_neo_attrs(obj, parents=False)504 res11 = nt.extract_neo_attrs(obj, parents=False, child_first=True)505 res21 = nt.extract_neo_attrs(obj, parents=False, child_first=False)506 del res00['i']507 del res10['i']508 del res20['i']509 del res01['i']510 del res11['i']511 del res21['i']512 del res00['j']513 del res10['j']514 del res20['j']515 del res01['j']516 del res11['j']517 del res21['j']518 self.assert_dicts_equal(targ, res00)519 self.assert_dicts_equal(targ, res10)520 self.assert_dicts_equal(targ, res20)521 self.assert_dicts_equal(targ, res01)522 self.assert_dicts_equal(targ, res11)523 self.assert_dicts_equal(targ, res21)524 def test__extract_neo_attrs__event_noparents_array(self):525 obj = self.block.list_children_by_class('Event')[0]526 targ = get_fake_values('Event', seed=obj.annotations['seed'])527 del targ['times']528 res00 = nt.extract_neo_attrs(obj, parents=False, skip_array=False)529 res10 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,530 child_first=True)531 res20 = nt.extract_neo_attrs(obj, parents=False, skip_array=False,532 child_first=False)533 res01 = nt.extract_neo_attrs(obj, parents=False)534 res11 = nt.extract_neo_attrs(obj, parents=False, child_first=True)535 res21 = nt.extract_neo_attrs(obj, parents=False, child_first=False)536 del res00['i']537 del res10['i']538 del res20['i']539 del res01['i']540 del res11['i']541 del res21['i']542 del res00['j']543 del res10['j']544 del res20['j']545 del res01['j']546 del res11['j']547 del res21['j']548 self.assert_dicts_equal(targ, res00)549 self.assert_dicts_equal(targ, res10)550 self.assert_dicts_equal(targ, res20)551 self.assert_dicts_equal(targ, res01)552 self.assert_dicts_equal(targ, res11)553 self.assert_dicts_equal(targ, res21)554 def test__extract_neo_attrs__spiketrain_parents_childfirst_noarray(self):555 obj = self.block.list_children_by_class('SpikeTrain')[0]556 blk = self.block557 seg = self.block.segments[0]558 rcg = self.block.channel_indexes[0]559 unit = self.block.channel_indexes[0].units[0]560 targ = get_fake_values('Block', seed=blk.annotations['seed'])561 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))562 targ.update(get_fake_values('ChannelIndex',563 seed=rcg.annotations['seed']))564 targ.update(get_fake_values('Unit', seed=unit.annotations['seed']))565 targ.update(get_fake_values('SpikeTrain',566 seed=obj.annotations['seed']))567 targ = strip_iter_values(targ)568 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=True)569 res1 = nt.extract_neo_attrs(obj, parents=True, skip_array=True,570 child_first=True)571 del res0['i']572 del res1['i']573 del res0['j']574 del res1['j']575 del res0['index'] # name clash between Block.index and ChannelIndex.index576 del res1['index']577 self.assertEqual(targ, res0)578 self.assertEqual(targ, res1)579 def test__extract_neo_attrs__epoch_parents_childfirst_noarray(self):580 obj = self.block.list_children_by_class('Epoch')[0]581 blk = self.block582 seg = self.block.segments[0]583 targ = get_fake_values('Block', seed=blk.annotations['seed'])584 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))585 targ.update(get_fake_values('Epoch', seed=obj.annotations['seed']))586 targ = strip_iter_values(targ)587 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=True)588 res1 = nt.extract_neo_attrs(obj, parents=True, skip_array=True,589 child_first=True)590 del res0['i']591 del res1['i']592 del res0['j']593 del res1['j']594 del res0['index'] # name clash between Block.index and ChannelIndex.index595 del res1['index']596 self.assertEqual(targ, res0)597 self.assertEqual(targ, res1)598 def test__extract_neo_attrs__event_parents_childfirst_noarray(self):599 obj = self.block.list_children_by_class('Event')[0]600 blk = self.block601 seg = self.block.segments[0]602 targ = get_fake_values('Block', seed=blk.annotations['seed'])603 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))604 targ.update(get_fake_values('Event', seed=obj.annotations['seed']))605 targ = strip_iter_values(targ)606 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=True)607 res1 = nt.extract_neo_attrs(obj, parents=True, skip_array=True,608 child_first=True)609 del res0['i']610 del res1['i']611 del res0['j']612 del res1['j']613 del res0['index'] # name clash between Block.index and ChannelIndex.index614 del res1['index']615 self.assertEqual(targ, res0)616 self.assertEqual(targ, res1)617 def test__extract_neo_attrs__spiketrain_parents_parentfirst_noarray(self):618 obj = self.block.list_children_by_class('SpikeTrain')[0]619 blk = self.block620 seg = self.block.segments[0]621 rcg = self.block.channel_indexes[0]622 unit = self.block.channel_indexes[0].units[0]623 targ = get_fake_values('SpikeTrain', seed=obj.annotations['seed'])624 targ.update(get_fake_values('Unit', seed=unit.annotations['seed']))625 targ.update(get_fake_values('ChannelIndex',626 seed=rcg.annotations['seed']))627 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))628 targ.update(get_fake_values('Block', seed=blk.annotations['seed']))629 targ = strip_iter_values(targ)630 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=True,631 child_first=False)632 del res0['i']633 del res0['j']634 del res0['index'] # name clash between Block.index and ChannelIndex.index635 self.assertEqual(targ, res0)636 def test__extract_neo_attrs__epoch_parents_parentfirst_noarray(self):637 obj = self.block.list_children_by_class('Epoch')[0]638 blk = self.block639 seg = self.block.segments[0]640 targ = get_fake_values('Epoch', seed=obj.annotations['seed'])641 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))642 targ.update(get_fake_values('Block', seed=blk.annotations['seed']))643 targ = strip_iter_values(targ)644 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=True,645 child_first=False)646 del res0['i']647 del res0['j']648 del res0['index'] # name clash between Block.index and ChannelIndex.index649 self.assertEqual(targ, res0)650 def test__extract_neo_attrs__event_parents_parentfirst_noarray(self):651 obj = self.block.list_children_by_class('Event')[0]652 blk = self.block653 seg = self.block.segments[0]654 targ = get_fake_values('Event', seed=obj.annotations['seed'])655 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))656 targ.update(get_fake_values('Block', seed=blk.annotations['seed']))657 targ = strip_iter_values(targ)658 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=True,659 child_first=False)660 del res0['i']661 del res0['j']662 del res0['index'] # name clash between Block.index and ChannelIndex.index663 self.assertEqual(targ, res0)664 def test__extract_neo_attrs__spiketrain_parents_childfirst_array(self):665 obj = self.block.list_children_by_class('SpikeTrain')[0]666 blk = self.block667 seg = self.block.segments[0]668 rcg = self.block.channel_indexes[0]669 unit = self.block.channel_indexes[0].units[0]670 targ = get_fake_values('Block', seed=blk.annotations['seed'])671 targ.update(get_fake_values('ChannelIndex',672 seed=rcg.annotations['seed']))673 targ['channel_names'] = rcg.channel_names674 targ.update(get_fake_values('Unit', seed=unit.annotations['seed']))675 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))676 targ.update(get_fake_values('SpikeTrain',677 seed=obj.annotations['seed']))678 del targ['times']679 res00 = nt.extract_neo_attrs(obj, parents=True, skip_array=False)680 res10 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,681 child_first=True)682 res01 = nt.extract_neo_attrs(obj, parents=True)683 res11 = nt.extract_neo_attrs(obj, parents=True, child_first=True)684 del res00['i']685 del res10['i']686 del res01['i']687 del res11['i']688 del res00['j']689 del res10['j']690 del res01['j']691 del res11['j']692 self.assert_dicts_equal(targ, res00)693 self.assert_dicts_equal(targ, res10)694 self.assert_dicts_equal(targ, res01)695 self.assert_dicts_equal(targ, res11)696 def test__extract_neo_attrs__epoch_parents_childfirst_array(self):697 obj = self.block.list_children_by_class('Epoch')[0]698 blk = self.block699 seg = self.block.segments[0]700 targ = get_fake_values('Block', seed=blk.annotations['seed'])701 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))702 targ.update(get_fake_values('Epoch', seed=obj.annotations['seed']))703 del targ['times']704 res00 = nt.extract_neo_attrs(obj, parents=True, skip_array=False)705 res10 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,706 child_first=True)707 res01 = nt.extract_neo_attrs(obj, parents=True)708 res11 = nt.extract_neo_attrs(obj, parents=True, child_first=True)709 del res00['i']710 del res10['i']711 del res01['i']712 del res11['i']713 del res00['j']714 del res10['j']715 del res01['j']716 del res11['j']717 self.assert_dicts_equal(targ, res00)718 self.assert_dicts_equal(targ, res10)719 self.assert_dicts_equal(targ, res01)720 self.assert_dicts_equal(targ, res11)721 def test__extract_neo_attrs__event_parents_childfirst_array(self):722 obj = self.block.list_children_by_class('Event')[0]723 blk = self.block724 seg = self.block.segments[0]725 targ = get_fake_values('Block', seed=blk.annotations['seed'])726 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))727 targ.update(get_fake_values('Event', seed=obj.annotations['seed']))728 del targ['times']729 res00 = nt.extract_neo_attrs(obj, parents=True, skip_array=False)730 res10 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,731 child_first=True)732 res01 = nt.extract_neo_attrs(obj, parents=True)733 res11 = nt.extract_neo_attrs(obj, parents=True, child_first=True)734 del res00['i']735 del res10['i']736 del res01['i']737 del res11['i']738 del res00['j']739 del res10['j']740 del res01['j']741 del res11['j']742 self.assert_dicts_equal(targ, res00)743 self.assert_dicts_equal(targ, res10)744 self.assert_dicts_equal(targ, res01)745 self.assert_dicts_equal(targ, res11)746 def test__extract_neo_attrs__spiketrain_parents_parentfirst_array(self):747 obj = self.block.list_children_by_class('SpikeTrain')[0]748 blk = self.block749 seg = self.block.segments[0]750 rcg = self.block.channel_indexes[0]751 unit = self.block.channel_indexes[0].units[0]752 targ = get_fake_values('SpikeTrain', seed=obj.annotations['seed'])753 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))754 targ.update(get_fake_values('Unit', seed=unit.annotations['seed']))755 targ.update(get_fake_values('ChannelIndex',756 seed=rcg.annotations['seed']))757 targ.update(get_fake_values('Block', seed=blk.annotations['seed']))758 del targ['times']759 del targ['index']760 del targ['channel_names']761 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,762 child_first=False)763 res1 = nt.extract_neo_attrs(obj, parents=True, child_first=False)764 del res0['i']765 del res1['i']766 del res0['j']767 del res1['j']768 del res0['index']769 del res1['index']770 del res0['channel_names']771 del res1['channel_names']772 self.assert_dicts_equal(targ, res0)773 self.assert_dicts_equal(targ, res1)774 def test__extract_neo_attrs__epoch_parents_parentfirst_array(self):775 obj = self.block.list_children_by_class('Epoch')[0]776 blk = self.block777 seg = self.block.segments[0]778 targ = get_fake_values('Epoch', seed=obj.annotations['seed'])779 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))780 targ.update(get_fake_values('Block', seed=blk.annotations['seed']))781 del targ['times']782 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,783 child_first=False)784 res1 = nt.extract_neo_attrs(obj, parents=True, child_first=False)785 del res0['i']786 del res1['i']787 del res0['j']788 del res1['j']789 self.assert_dicts_equal(targ, res0)790 self.assert_dicts_equal(targ, res1)791 def test__extract_neo_attrs__event_parents_parentfirst_array(self):792 obj = self.block.list_children_by_class('Event')[0]793 blk = self.block794 seg = self.block.segments[0]795 targ = get_fake_values('Event', seed=obj.annotations['seed'])796 targ.update(get_fake_values('Segment', seed=seg.annotations['seed']))797 targ.update(get_fake_values('Block', seed=blk.annotations['seed']))798 del targ['times']799 res0 = nt.extract_neo_attrs(obj, parents=True, skip_array=False,800 child_first=False)801 res1 = nt.extract_neo_attrs(obj, parents=True, child_first=False)802 del res0['i']803 del res1['i']804 del res0['j']805 del res1['j']806 self.assert_dicts_equal(targ, res0)807 self.assert_dicts_equal(targ, res1)808class GetAllSpiketrainsTestCase(unittest.TestCase):809 def test__get_all_spiketrains__spiketrain(self):810 obj = fake_neo('SpikeTrain', seed=0, n=5)811 res0 = nt.get_all_spiketrains(obj)812 targ = obj813 self.assertEqual(1, len(res0))814 assert_same_sub_schema(targ, res0[0])815 def test__get_all_spiketrains__unit(self):816 obj = fake_neo('Unit', seed=0, n=7)817 obj.spiketrains.append(obj.spiketrains[0])818 res0 = nt.get_all_spiketrains(obj)819 targ = fake_neo('Unit', seed=0, n=7).spiketrains820 self.assertTrue(len(res0) > 0)821 self.assertEqual(len(targ), len(res0))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!