Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

test_neomatlabio.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. """
  3. Tests of neo.io.neomatlabio
  4. """
  5. # needed for python 3 compatibility
  6. from __future__ import absolute_import, division
  7. import unittest
  8. import quantities as pq
  9. from neo import Block, Segment, SpikeTrain
  10. from neo.test.iotest.common_io_test import BaseTestIO
  11. from neo.io.neomatlabio import NeoMatlabIO, HAVE_SCIPY
  12. @unittest.skipUnless(HAVE_SCIPY, "requires scipy")
  13. class TestNeoMatlabIO(BaseTestIO, unittest.TestCase):
  14. ioclass = NeoMatlabIO
  15. files_to_test = []
  16. files_to_download = []
  17. def test_write_read_single_spike(self):
  18. block1 = Block()
  19. seg = Segment('segment1')
  20. spiketrain = SpikeTrain([1] * pq.s, t_stop=10 * pq.s, sampling_rate=1 * pq.Hz)
  21. block1.segments.append(seg)
  22. seg.spiketrains.append(spiketrain)
  23. # write block
  24. filename = BaseTestIO.get_filename_path(self, 'matlabiotestfile.mat')
  25. io1 = self.ioclass(filename)
  26. io1.write_block(block1)
  27. # read block
  28. io2 = self.ioclass(filename)
  29. block2 = io2.read_block()
  30. self.assertEqual(block1.segments[0].spiketrains[0],
  31. block2.segments[0].spiketrains[0])
  32. if __name__ == "__main__":
  33. unittest.main()