Skip to content

Indicate what parameters are optional #471

@bendichter

Description

@bendichter

Feature Request

It's not clear to me from the pynwb docs what arguments are required and what arguments are optional.

If I run:

from pynwb import NWBFile
NWBFile()

I get the following error:

TypeError: missing argument 'source', missing argument 'session_description', missing argument 'identifier', missing argument 'session_start_time'

which tells me which arguments are required. If I then run:

from pynwb import NWBFile
from datetime import datetime
NWBFile(source='source', session_description='session_description',
        identifier='identifier', session_start_time=datetime.now())

no error, but what about the other arguments? The docs list many parameters:

source (str) – the source of the data
session_description (str) – a description of the session where this data was generated
identifier (str) – a unique text identifier for the file
session_start_time (datetime or str) – the start time of the recording session
file_create_date (ndarray or list or tuple or Dataset or DataChunkIterator or DataIO or FORMDataset or datetime or str) – the time the file was created and subsequent modifications made
experimenter (str) – name of person who performed experiment
experiment_description (str) – general description of the experiment
session_id (str) – lab-specific ID for the session
institution (str) – institution(s) where experiment is performed
lab (str) – lab where experiment was performed
acquisition (list or tuple) – Raw TimeSeries objects belonging to this NWBFile
stimulus (list or tuple) – Stimulus TimeSeries objects belonging to this NWBFile
stimulus_template (list or tuple) – Stimulus template TimeSeries objects belonging to this NWBFile
epochs (Epochs) – Epoch objects belonging to this NWBFile
epoch_tags (tuple or list or set) – A sorted list of tags used across all epochs
modules (list or tuple) – ProcessingModule objects belonging to this NWBFile
ec_electrodes (ElectrodeTable or Iterable) – the ElectrodeTable that belongs to this NWBFile
ec_electrode_groups (Iterable) – the ElectrodeGroups that belong to this NWBFile
ic_electrodes (list or tuple) – IntracellularElectrodes that belong to this NWBFile
imaging_planes (list or tuple) – ImagingPlanes that belong to this NWBFile
ogen_sites (list or tuple) – OptogeneticStimulusSites that belong to this NWBFile
devices (list or tuple) – Device objects belonging to this NWBFile
subject (Subject) – subject metadata

4 of those are required and the rest are not. As far as I can tell the only way to determine this is by trial and error. The input arguments are obscured by docval, so my standard PyCharm tricks don't work either.

There's a standard way to do this with the various docstring formats (Google, numpy, reStructuredText etc.), but we are using docval, so I don't really know how to handle it. Perhaps we could add the ability to mark arguments as optional, if it does not already exist?

  • Have you ensured the feature or change was not already reported ?
  • Have you included a brief and descriptive title?
  • Have you included a clear description of the problem you are trying to solve?
  • Have you included a minimal code snippet that reproduces the issue you are encountering?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted: good first issuerequest for community contributions that are good for new contributorspriority: lowalternative solution already working and/or relevant to only specific user(s)topic: docsissues related to documentation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions