From 8a2107714fe684283657821237a931af4fbbc04b Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 30 Jul 2018 19:24:44 +0200 Subject: [PATCH] Create a separate file for the Device object The Device object is currently defined in ecephys.py although icephys, ecephys and ophys use it. This is unfortunate and will be changed in this commit. Fix #443. --- docs/gallery/domain/ecephys.py | 2 +- docs/gallery/domain/icephys.py | 4 ++-- src/pynwb/__init__.py | 1 + src/pynwb/device.py | 18 ++++++++++++++++++ src/pynwb/ecephys.py | 16 +--------------- 5 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 src/pynwb/device.py diff --git a/docs/gallery/domain/ecephys.py b/docs/gallery/domain/ecephys.py index d0f231fcd..7a114e3f2 100644 --- a/docs/gallery/domain/ecephys.py +++ b/docs/gallery/domain/ecephys.py @@ -45,7 +45,7 @@ device = nwbfile.create_device(name='trodes_rig123', source="a source") ####################### -# Once you have created the :py:class:`~pynwb.ecephys.Device`, you can create an +# Once you have created the :py:class:`~pynwb.device.Device`, you can create an # :py:class:`~pynwb.ecephys.ElectrodeGroup`. electrode_name = 'tetrode1' diff --git a/docs/gallery/domain/icephys.py b/docs/gallery/domain/icephys.py index 4f66675ed..8e8599b80 100644 --- a/docs/gallery/domain/icephys.py +++ b/docs/gallery/domain/icephys.py @@ -31,8 +31,8 @@ # Device metadata # ^^^^^^^^^^^^^^^ # -# Device metadata is represented by :py:class:`~pynwb.ecephys.Device` objects. -# To create a device, you can use the :py:class:`~pynwb.ecephys.Device` instance method +# Device metadata is represented by :py:class:`~pynwb.device.Device` objects. +# To create a device, you can use the :py:class:`~pynwb.device.Device` instance method # :py:meth:`~pynwb.file.NWBFile.create_device`. device = nwbfile.create_device(name='Heka ITC-1600', source='a source') diff --git a/src/pynwb/__init__.py b/src/pynwb/__init__.py index dc3b26a58..820aee91a 100644 --- a/src/pynwb/__init__.py +++ b/src/pynwb/__init__.py @@ -232,6 +232,7 @@ def __init__(self, **kwargs): from .file import NWBFile # noqa: E402, F401 from . import behavior # noqa: F401,E402 +from . import device # noqa: F401,E402 from . import ecephys # noqa: F401,E402 from . import epoch # noqa: F401,E402 from . import icephys # noqa: F401,E402 diff --git a/src/pynwb/device.py b/src/pynwb/device.py new file mode 100644 index 000000000..04f6b60af --- /dev/null +++ b/src/pynwb/device.py @@ -0,0 +1,18 @@ +from .form.utils import docval, call_docval_func +from . import register_class, CORE_NAMESPACE +from .core import NWBContainer + + +@register_class('Device', CORE_NAMESPACE) +class Device(NWBContainer): + """ + """ + + __nwbfields__ = ('name',) + + @docval({'name': 'name', 'type': str, 'doc': 'the name of this device'}, + {'name': 'source', 'type': str, 'doc': 'the source of the data'}, + {'name': 'parent', 'type': 'NWBContainer', + 'doc': 'The parent NWBContainer for this NWBContainer', 'default': None}) + def __init__(self, **kwargs): + call_docval_func(super(Device, self).__init__, kwargs) diff --git a/src/pynwb/ecephys.py b/src/pynwb/ecephys.py index 46bfe7060..3c1b06014 100644 --- a/src/pynwb/ecephys.py +++ b/src/pynwb/ecephys.py @@ -8,21 +8,7 @@ from . import register_class, CORE_NAMESPACE from .base import TimeSeries, _default_resolution, _default_conversion from .core import NWBContainer, NWBTable, NWBTableRegion, NWBDataInterface, MultiContainerInterface - - -@register_class('Device', CORE_NAMESPACE) -class Device(NWBContainer): - """ - """ - - __nwbfields__ = ('name',) - - @docval({'name': 'name', 'type': str, 'doc': 'the name of this device'}, - {'name': 'source', 'type': str, 'doc': 'the source of the data'}, - {'name': 'parent', 'type': 'NWBContainer', - 'doc': 'The parent NWBContainer for this NWBContainer', 'default': None}) - def __init__(self, **kwargs): - call_docval_func(super(Device, self).__init__, kwargs) +from .device import Device @register_class('ElectrodeGroup', CORE_NAMESPACE)