tmp.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from neo.core import AnalogSignal, SpikeTrain, Block
  2. from neo.test.generate_datasets import fake_neo, clone_object
  3. from neo.test.tools import (assert_neo_object_is_compliant,
  4. assert_same_sub_schema)
  5. self_nchildren = 2
  6. blk = fake_neo(Block, seed=0, n=self_nchildren)
  7. self_unit1, self_unit2, self_unit3, self_unit4 = blk.list_units
  8. self_seg1, self_seg2 = blk.segments
  9. self_targobj = self_seg1
  10. self_seed1 = self_seg1.annotations['seed']
  11. self_seed2 = self_seg2.annotations['seed']
  12. del self_seg1.annotations['i']
  13. del self_seg2.annotations['i']
  14. del self_seg1.annotations['j']
  15. del self_seg2.annotations['j']
  16. self_sigarrs1 = self_seg1.analogsignals
  17. self_sigarrs2 = self_seg2.analogsignals
  18. self_irsigs1 = self_seg1.irregularlysampledsignals
  19. self_irsigs2 = self_seg2.irregularlysampledsignals
  20. self_trains1 = self_seg1.spiketrains
  21. self_trains2 = self_seg2.spiketrains
  22. self_epcs1 = self_seg1.epochs
  23. self_epcs2 = self_seg2.epochs
  24. self_evts1 = self_seg1.events
  25. self_evts2 = self_seg2.events
  26. self_sigarrs1a = clone_object(self_sigarrs1, n=2)
  27. self_irsigs1a = clone_object(self_irsigs1)
  28. self_trains1a = clone_object(self_trains1)
  29. self_epcs1a = clone_object(self_epcs1)
  30. self_evts1a = clone_object(self_evts1)
  31. seg1a = fake_neo(Block, seed=self_seed1, n=self_nchildren).segments[0]
  32. assert_same_sub_schema(self_seg1, seg1a)
  33. seg1a.annotations.pop("i") # check_creation doesn't expect these
  34. seg1a.annotations.pop("j") # so we delete them
  35. self_check_creation(seg1a)
  36. seg1a.epochs.append(self_epcs2[0])
  37. seg1a.annotate(seed=self_seed2)
  38. seg1a.merge(self_seg2)
  39. self_check_creation(seg1a)
  40. assert_same_sub_schema(self_sigarrs1a + self_sigarrs2,
  41. seg1a.analogsignals)
  42. assert_same_sub_schema(self_irsigs1a + self_irsigs2,
  43. seg1a.irregularlysampledsignals)
  44. assert_same_sub_schema(self_epcs1 + self_epcs2, seg1a.epochs)
  45. assert_same_sub_schema(self_evts1 + self_evts2, seg1a.events)
  46. assert_same_sub_schema(self_trains1 + self_trains2, seg1a.spiketrains)