python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

NixIO does not support writing of numpy array_annotations of dtype datetime

Open JuliaSprenger opened this issue 3 years ago • 0 comments

Describe the bug An object with an array_annotation of dtype=datetime.datetime can not be saved as this raises an error in nixio. _nixio_write_property needs to be adjusted to convert datetime objects in array annotations before saving these.

To Reproduce

import datetime
import numpy as np
import neo
import quantities as pq

block = neo.Block()
block.segments.append(neo.Segment())
event = neo.Event([1,2,3]*pq.s)
event.array_annotate(dates=np.array([datetime.datetime.now()]*3))
block.segments[0].events.append(event)

with neo.NixIO('testfile.nix','ow') as io:
    io.write_block(block)

Expected behaviour The file should be saved without errors.

Environment:

  • OS: Linux
  • Python version 3.8
  • Neo version: current master
  • NumPy version 1.20.3
  • NixIO version 1.5.3

Additional context We should check that all allowed annotation types are correctly saved when used as numpy dtype. The full list of types can be found here

JuliaSprenger avatar Nov 07 '22 08:11 JuliaSprenger