Skip to content

Commit cd8328b

Browse files
committed
test usecols
1 parent 7faaee3 commit cd8328b

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

neo/test/iotest/test_asciisignalio.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,28 @@ def test_skiprows(self):
155155

156156
os.remove(filename)
157157

158-
# test usecols
158+
def test_usecols(self):
159+
filename = 'test_usecols.txt'
160+
sample_data = [
161+
(-65, -65, -65, 0.5),
162+
(-64.8, -64.5, -64.0, 0.6),
163+
(-64.6, -64.2, -77.0, 0.7),
164+
(-64.3, -64.0, -99.9, 0.8),
165+
(-66, -64.3, -61.0, 1.4),
166+
]
167+
with open(filename, 'w') as datafile:
168+
for row in sample_data:
169+
datafile.write("\t ".join(map(str, row)) + "\t\n")
170+
io = AsciiSignalIO(filename, usecols=3)
171+
block = io.read_block()
172+
signal = block.segments[0].analogsignals[0]
173+
self.assertEqual(signal.shape, (5, 1))
174+
self.assertEqual(len(block.segments[0].analogsignals[0]), 5)
175+
self.assertEqual(len(block.segments[0].analogsignals), 1)
176+
self.assertEqual(signal.units, pq.V)
177+
178+
os.remove(filename)
179+
159180

160181
def test_timecolumn(self):
161182
sample_data = np.random.uniform(size=(200, 3))

0 commit comments

Comments
 (0)