Skip to content

Commit 6321149

Browse files
committed
[test-nixio] Test different types of Neo annotations
1 parent c260958 commit 6321149

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

neo/test/iotest/test_nixio.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,27 @@ def test_annotations_special_cases(self):
13301330

13311331
# TODO: multi dimensional value (GH Issue #501)
13321332

1333+
def test_annotation_types(self):
1334+
annotations = {
1335+
"somedate": self.rdate(),
1336+
"somequantity": self.rquant(10, pq.ms),
1337+
"somestring": self.rsentence(3),
1338+
"somebytes": bytes(self.rsentence(4), "utf8"),
1339+
"npfloat": np.float(10),
1340+
"nparray": np.array([1, 2, 400]),
1341+
"emptystr": "",
1342+
}
1343+
wblock = Block("annotation_block", **annotations)
1344+
self.writer.write_block(wblock)
1345+
rblock = self.writer.read_block(neoname="annotation_block")
1346+
for k in annotations:
1347+
orig = annotations[k]
1348+
readval = rblock.annotations[k]
1349+
if isinstance(orig, np.ndarray):
1350+
np.testing.assert_almost_equal(orig, readval)
1351+
else:
1352+
self.assertEqual(annotations[k], rblock.annotations[k])
1353+
13331354

13341355
@unittest.skipUnless(HAVE_NIX, "Requires NIX")
13351356
class NixIOReadTest(NixIOTest):

0 commit comments

Comments
 (0)