Skip to content

Commit

Permalink
Add __all__ declarations to multiple modules for improved API clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
bendichter committed Jan 27, 2025
1 parent c3497b2 commit f474814
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/pynwb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/pynwb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/pynwb/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 11 additions & 0 deletions src/pynwb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
1 change: 1 addition & 0 deletions src/pynwb/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from . import register_class, CORE_NAMESPACE
from .core import NWBContainer

__all__ = ['Device']

@register_class('Device', CORE_NAMESPACE)
class Device(NWBContainer):
Expand Down
10 changes: 10 additions & 0 deletions src/pynwb/ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions src/pynwb/epoch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 10 additions & 0 deletions src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
18 changes: 18 additions & 0 deletions src/pynwb/icephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions src/pynwb/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
from .device import Device


__all__ = [
'ImageSeries',
'IndexSeries',
'OpticalSeries',
'GrayscaleImage',
'RGBImage',
'RGBAImage'
]


@register_class('ImageSeries', CORE_NAMESPACE)
class ImageSeries(TimeSeries):
'''
Expand Down
7 changes: 7 additions & 0 deletions src/pynwb/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions src/pynwb/ogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from .core import NWBContainer
from .device import Device

__all__ = [
'OptogeneticStimulusSite',
'OptogeneticSeries'
]

@register_class('OptogeneticStimulusSite', CORE_NAMESPACE)
class OptogeneticStimulusSite(NWBContainer):
Expand Down
14 changes: 14 additions & 0 deletions src/pynwb/ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions src/pynwb/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from . import get_type_map as tm
from hdmf.utils import docval, get_docval

__all__ = ['HERD']

class HERD(hdmf_HERD):
"""
Expand Down
13 changes: 13 additions & 0 deletions src/pynwb/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
6 changes: 6 additions & 0 deletions src/pynwb/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f474814

Please sign in to comment.