From c3497b2f624c7eeff05a6ecf086bf24fe142c404 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Mon, 27 Jan 2025 10:40:40 -0600 Subject: [PATCH 1/5] chore: update .gitignore to include venv/ --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 95f08686e..88c381afc 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,5 @@ _version.py .core_typemap_version core_typemap.pkl + +/venv \ No newline at end of file From f47481419f08225003179d63fcf57cd00cbdfd51 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Mon, 27 Jan 2025 11:15:46 -0600 Subject: [PATCH 2/5] Add `__all__` declarations to multiple modules for improved API clarity --- src/pynwb/__init__.py | 26 ++++++++++++++++++++++++++ src/pynwb/base.py | 11 +++++++++++ src/pynwb/behavior.py | 11 +++++++++++ src/pynwb/core.py | 11 +++++++++++ src/pynwb/device.py | 1 + src/pynwb/ecephys.py | 10 ++++++++++ src/pynwb/epoch.py | 1 + src/pynwb/file.py | 10 ++++++++++ src/pynwb/icephys.py | 18 ++++++++++++++++++ src/pynwb/image.py | 10 ++++++++++ src/pynwb/misc.py | 7 +++++++ src/pynwb/ogen.py | 4 ++++ src/pynwb/ophys.py | 14 ++++++++++++++ src/pynwb/resources.py | 1 + src/pynwb/spec.py | 13 +++++++++++++ src/pynwb/validate.py | 6 ++++++ 16 files changed, 154 insertions(+) diff --git a/src/pynwb/__init__.py b/src/pynwb/__init__.py index 7931322a8..5d16c7d5f 100644 --- a/src/pynwb/__init__.py +++ b/src/pynwb/__init__.py @@ -613,6 +613,32 @@ def read_nwb(**kwargs): from hdmf.data_utils import DataChunkIterator # noqa: F401,E402 from hdmf.backends.hdf5 import H5DataIO # noqa: F401,E402 +__all__ = [ + # Functions + 'get_type_map', + 'get_manager', + 'load_namespaces', + 'available_namespaces', + 'register_class', + 'register_map', + 'get_class', + 'load_type_config', + 'get_loaded_type_config', + 'unload_type_config', + 'read_nwb', + 'get_nwbfile_version', + + # Classes + 'NWBHDF5IO', + 'NWBContainer', + 'NWBData', + 'TimeSeries', + 'ProcessingModule', + 'NWBFile', + 'DataChunkIterator', + 'H5DataIO' +] + from ._due import due, BibTeX # noqa: E402 diff --git a/src/pynwb/base.py b/src/pynwb/base.py index 8b4daf48f..6e2d4c5b7 100644 --- a/src/pynwb/base.py +++ b/src/pynwb/base.py @@ -12,6 +12,17 @@ from .core import NWBDataInterface, MultiContainerInterface, NWBData +__all__ = [ + 'ProcessingModule', + 'TimeSeries', + 'Image', + 'ImageReferences', + 'Images', + 'TimeSeriesReferenceVectorData', + 'TimeSeriesReference' +] + + @register_class('ProcessingModule', CORE_NAMESPACE) class ProcessingModule(MultiContainerInterface): """ Processing module. This is a container for one or more containers diff --git a/src/pynwb/behavior.py b/src/pynwb/behavior.py index d4d43d515..2aa9472ea 100644 --- a/src/pynwb/behavior.py +++ b/src/pynwb/behavior.py @@ -7,6 +7,17 @@ from .misc import IntervalSeries from .base import TimeSeries +__all__ = [ + 'SpatialSeries', + 'BehavioralEpochs', + 'BehavioralEvents', + 'BehavioralTimeSeries', + 'PupilTracking', + 'EyeTracking', + 'CompassDirection', + 'Position' +] + @register_class('SpatialSeries', CORE_NAMESPACE) class SpatialSeries(TimeSeries): diff --git a/src/pynwb/core.py b/src/pynwb/core.py index f9ae2bd2f..7a656adcc 100644 --- a/src/pynwb/core.py +++ b/src/pynwb/core.py @@ -13,6 +13,17 @@ from pynwb import get_type_map +__all__ = [ + 'NWBMixin', + 'NWBContainer', + 'NWBDataInterface', + 'NWBData', + 'ScratchData', + 'NWBTable', + 'MultiContainerInterface' +] + + def _not_parent(arg): return arg['name'] != 'parent' diff --git a/src/pynwb/device.py b/src/pynwb/device.py index f842776ae..31e490f0a 100644 --- a/src/pynwb/device.py +++ b/src/pynwb/device.py @@ -3,6 +3,7 @@ from . import register_class, CORE_NAMESPACE from .core import NWBContainer +__all__ = ['Device'] @register_class('Device', CORE_NAMESPACE) class Device(NWBContainer): diff --git a/src/pynwb/ecephys.py b/src/pynwb/ecephys.py index 07d584a4f..739264e21 100644 --- a/src/pynwb/ecephys.py +++ b/src/pynwb/ecephys.py @@ -11,6 +11,16 @@ from .core import NWBContainer, NWBDataInterface, MultiContainerInterface from .device import Device +__all__ = [ + 'ElectrodeGroup', + 'ElectricalSeries', + 'SpikeEventSeries', + 'EventDetection', + 'LFP', + 'FilteredEphys', + 'FeatureExtraction' +] + @register_class('ElectrodeGroup', CORE_NAMESPACE) class ElectrodeGroup(NWBContainer): diff --git a/src/pynwb/epoch.py b/src/pynwb/epoch.py index 9cccc5db5..931080788 100644 --- a/src/pynwb/epoch.py +++ b/src/pynwb/epoch.py @@ -7,6 +7,7 @@ from . import register_class, CORE_NAMESPACE from .base import TimeSeries, TimeSeriesReferenceVectorData, TimeSeriesReference +__all__ = ['TimeIntervals'] @register_class('TimeIntervals', CORE_NAMESPACE) class TimeIntervals(DynamicTable): diff --git a/src/pynwb/file.py b/src/pynwb/file.py index a447c126d..84dc1b5b8 100644 --- a/src/pynwb/file.py +++ b/src/pynwb/file.py @@ -26,6 +26,16 @@ from .core import NWBContainer, NWBDataInterface, MultiContainerInterface, ScratchData, LabelledDict +__all__ = [ + 'LabMetaData', + 'Subject', + 'NWBFile', + 'ElectrodeTable', + 'TrialTable', + 'InvalidTimesTable' +] + + def _not_parent(arg): return arg['name'] != 'parent' diff --git a/src/pynwb/icephys.py b/src/pynwb/icephys.py index ec44a2bd8..4e32094ee 100644 --- a/src/pynwb/icephys.py +++ b/src/pynwb/icephys.py @@ -11,6 +11,24 @@ from .core import NWBContainer from .device import Device +__all__ = [ + 'IntracellularElectrode', + 'PatchClampSeries', + 'CurrentClampSeries', + 'IZeroClampSeries', + 'CurrentClampStimulusSeries', + 'VoltageClampSeries', + 'VoltageClampStimulusSeries', + 'IntracellularElectrodesTable', + 'IntracellularStimuliTable', + 'IntracellularResponsesTable', + 'IntracellularRecordingsTable', + 'SimultaneousRecordingsTable', + 'SequentialRecordingsTable', + 'RepetitionsTable', + 'ExperimentalConditionsTable' +] + def ensure_unit(self, name, current_unit, unit, nwb_version): """A helper to ensure correct unit used. diff --git a/src/pynwb/image.py b/src/pynwb/image.py index c775297d7..519d24004 100644 --- a/src/pynwb/image.py +++ b/src/pynwb/image.py @@ -17,6 +17,16 @@ from .device import Device +__all__ = [ + 'ImageSeries', + 'IndexSeries', + 'OpticalSeries', + 'GrayscaleImage', + 'RGBImage', + 'RGBAImage' +] + + @register_class('ImageSeries', CORE_NAMESPACE) class ImageSeries(TimeSeries): ''' diff --git a/src/pynwb/misc.py b/src/pynwb/misc.py index 14c2e08d1..8f7383d59 100644 --- a/src/pynwb/misc.py +++ b/src/pynwb/misc.py @@ -11,6 +11,13 @@ from .ecephys import ElectrodeGroup from hdmf.common import DynamicTable, DynamicTableRegion +__all__ = [ + 'AnnotationSeries', + 'AbstractFeatureSeries', + 'IntervalSeries', + 'Units', + 'DecompositionSeries' +] @register_class('AnnotationSeries', CORE_NAMESPACE) class AnnotationSeries(TimeSeries): diff --git a/src/pynwb/ogen.py b/src/pynwb/ogen.py index af11842e4..f433d1bc2 100644 --- a/src/pynwb/ogen.py +++ b/src/pynwb/ogen.py @@ -5,6 +5,10 @@ from .core import NWBContainer from .device import Device +__all__ = [ + 'OptogeneticStimulusSite', + 'OptogeneticSeries' +] @register_class('OptogeneticStimulusSite', CORE_NAMESPACE) class OptogeneticStimulusSite(NWBContainer): diff --git a/src/pynwb/ophys.py b/src/pynwb/ophys.py index 6f1483079..660af4cb9 100644 --- a/src/pynwb/ophys.py +++ b/src/pynwb/ophys.py @@ -11,6 +11,20 @@ from .core import NWBContainer, MultiContainerInterface, NWBDataInterface from .device import Device +__all__ = [ + 'OpticalChannel', + 'ImagingPlane', + 'OnePhotonSeries', + 'TwoPhotonSeries', + 'CorrectedImageStack', + 'MotionCorrection', + 'PlaneSegmentation', + 'ImageSegmentation', + 'RoiResponseSeries', + 'DfOverF', + 'Fluorescence' +] + @register_class('OpticalChannel', CORE_NAMESPACE) class OpticalChannel(NWBContainer): diff --git a/src/pynwb/resources.py b/src/pynwb/resources.py index acdc22b12..e2d0acda4 100644 --- a/src/pynwb/resources.py +++ b/src/pynwb/resources.py @@ -2,6 +2,7 @@ from . import get_type_map as tm from hdmf.utils import docval, get_docval +__all__ = ['HERD'] class HERD(hdmf_HERD): """ diff --git a/src/pynwb/spec.py b/src/pynwb/spec.py index fe97b6eae..7c3a65173 100644 --- a/src/pynwb/spec.py +++ b/src/pynwb/spec.py @@ -8,6 +8,19 @@ from . import CORE_NAMESPACE +__all__ = [ + 'NWBRefSpec', + 'NWBAttributeSpec', + 'NWBLinkSpec', + 'NWBDtypeSpec', + 'NWBDatasetSpec', + 'NWBGroupSpec', + 'NWBNamespace', + 'NWBNamespaceBuilder', + 'export_spec' # Re-exported from hdmf.spec.write +] + + def __swap_inc_def(cls): args = get_docval(cls.__init__) clsname = 'NWB%s' % cls.__name__ diff --git a/src/pynwb/validate.py b/src/pynwb/validate.py index 880f860a6..ddd93f2e5 100644 --- a/src/pynwb/validate.py +++ b/src/pynwb/validate.py @@ -14,6 +14,12 @@ from pynwb.spec import NWBDatasetSpec, NWBGroupSpec, NWBNamespace +__all__ = [ + 'validate', + 'get_cached_namespaces_to_validate' +] + + def _print_errors(validation_errors: list): if validation_errors: print(" - found the following errors:", file=sys.stderr) From c7c06fc5513517bb5ac0bc6895c2e2c9bf391dc8 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Mon, 27 Jan 2025 14:30:45 -0500 Subject: [PATCH 3/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2230cbd49..27916bddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## PyNWB 3.0.0 (Upcoming) ### Enhancements and minor changes +- Added `__all__` to modules. @bendichter [#2021](https://github.com/NeurodataWithoutBorders/pynwb/pull/2021) - Added `pynwb.read_nwb` convenience method to simplify reading an NWBFile written with any backend @h-mayorquin [#1994](https://github.com/NeurodataWithoutBorders/pynwb/pull/1994) - Added support for NWB schema 2.8.0. @rly [#2001](https://github.com/NeurodataWithoutBorders/pynwb/pull/2001) - Removed `SpatialSeries.bounds` field that was not functional. This will be fixed in a future release. @rly [#1907](https://github.com/NeurodataWithoutBorders/pynwb/pull/1907), [#1996](https://github.com/NeurodataWithoutBorders/pynwb/pull/1996) From 9e31b3381f3476dad343c5159f85c75fb6ce029a Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Tue, 28 Jan 2025 16:23:20 -0600 Subject: [PATCH 4/5] Fix docstring formatting for create_icephys_testfile to include proper class references --- src/pynwb/testing/icephys_testutils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pynwb/testing/icephys_testutils.py b/src/pynwb/testing/icephys_testutils.py index 3de4619d4..d83a7034b 100644 --- a/src/pynwb/testing/icephys_testutils.py +++ b/src/pynwb/testing/icephys_testutils.py @@ -60,10 +60,10 @@ def create_icephys_testfile(filename=None, add_custom_columns=True, randomize_da :param randomize_data: Randomize data values in the stimulus and response :type randomize_data: bool - :returns: NWBFile object with icephys data created for writing. NOTE: If filename is provided then + :returns: :py:class:`~pynwb.file.NWBFile` object with icephys data created for writing. NOTE: If filename is provided then the file is written to disk, but the function does not read the file back. If - you want to use the file from disk then you will need to read it with NWBHDF5IO. - :rtype: NWBFile + you want to use the file from disk then you will need to read it with :py:class:`~pynwb.NWBHDF5IO`. + :rtype: :py:class:`~pynwb.file.NWBFile` """ nwbfile = NWBFile( session_description='my first synthetic recording', From 3ca6ffe26aa2fb4c2edff828d17305e602bc494d Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Tue, 28 Jan 2025 16:34:29 -0600 Subject: [PATCH 5/5] Fix docstring formatting in create_icephys_testfile for improved readability --- src/pynwb/testing/icephys_testutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pynwb/testing/icephys_testutils.py b/src/pynwb/testing/icephys_testutils.py index d83a7034b..aed8c2653 100644 --- a/src/pynwb/testing/icephys_testutils.py +++ b/src/pynwb/testing/icephys_testutils.py @@ -60,8 +60,8 @@ def create_icephys_testfile(filename=None, add_custom_columns=True, randomize_da :param randomize_data: Randomize data values in the stimulus and response :type randomize_data: bool - :returns: :py:class:`~pynwb.file.NWBFile` object with icephys data created for writing. NOTE: If filename is provided then - the file is written to disk, but the function does not read the file back. If + :returns: :py:class:`~pynwb.file.NWBFile` object with icephys data created for writing. NOTE: If filename is + provided then the file is written to disk, but the function does not read the file back. If you want to use the file from disk then you will need to read it with :py:class:`~pynwb.NWBHDF5IO`. :rtype: :py:class:`~pynwb.file.NWBFile` """