docs: add NumPy-style docstrings for ReadTheDocs#96
docs: add NumPy-style docstrings for ReadTheDocs#96oliveira-caio wants to merge 45 commits intosensorium-competition:mainfrom
Conversation
Add extensions for autodoc, napoleon, mathjax, intersphinx, and viewcode. Configure napoleon for NumPy-style docstrings with math rendering support and cross-references to Python, NumPy, SciPy, and PyTorch documentation.
- Add autodoc_mock_imports for heavy dependencies (torch, numpy, etc.) - Create api.rst with single-page API reference for all modules - Update index.rst to include API Reference section
Document package architecture, class relationships, data flow, potential bugs, and docstring requirements with priority levels.
- experiment.py: Experiment class, interpolate, get_valid_range - datasets.py: ChunkDataset class, __getitem__ - dataloaders.py: get_multisession_dataloader, get_multisession_concat_dataloader - configs.py: module-level docstring with exports documentation
- Create _static directory to fix warning - Fix initialize_statistics, initialize_transforms docstrings (datasets.py) - Fix get_screen_sample_mask_from_meta_conditions docstring (datasets.py) - Fix get_full_valid_sample_times docstring (datasets.py) - Fix add_behavior_as_channels docstring (utils.py) - Remove duplicate device_names property docstring (experiment.py)
interpolators.py: - Interpolator base class and factory method - SequenceInterpolator with linear interpolation math - ScreenInterpolator for visual stimuli - PhaseShiftedSequenceInterpolator - ScreenTrial and subclasses (ImageTrial, VideoTrial, BlankTrial) intervals.py: - TimeInterval class - All interval manipulation functions utils.py: - LongCycler, ShortCycler - FastSessionDataLoader with full parameter documentation
Add extensions for autodoc, napoleon, mathjax, intersphinx, and viewcode. Configure napoleon for NumPy-style docstrings with math rendering support and cross-references to Python, NumPy, SciPy, and PyTorch documentation.
- Add autodoc_mock_imports for heavy dependencies (torch, numpy, etc.) - Create api.rst with single-page API reference for all modules - Update index.rst to include API Reference section
Document package architecture, class relationships, data flow, potential bugs, and docstring requirements with priority levels.
- experiment.py: Experiment class, interpolate, get_valid_range - datasets.py: ChunkDataset class, __getitem__ - dataloaders.py: get_multisession_dataloader, get_multisession_concat_dataloader - configs.py: module-level docstring with exports documentation
- Create _static directory to fix warning - Fix initialize_statistics, initialize_transforms docstrings (datasets.py) - Fix get_screen_sample_mask_from_meta_conditions docstring (datasets.py) - Fix get_full_valid_sample_times docstring (datasets.py) - Fix add_behavior_as_channels docstring (utils.py) - Remove duplicate device_names property docstring (experiment.py)
interpolators.py: - Interpolator base class and factory method - SequenceInterpolator with linear interpolation math - ScreenInterpolator for visual stimuli - PhaseShiftedSequenceInterpolator - ScreenTrial and subclasses (ImageTrial, VideoTrial, BlankTrial) intervals.py: - TimeInterval class - All interval manipulation functions utils.py: - LongCycler, ShortCycler - FastSessionDataLoader with full parameter documentation
…o/experanto into claude/add-docstrings-KhA9Q
- datasets.py: get_data_key_from_root_folder - interpolators.py: rescale_frame - utils.py: SessionBatchSampler.__init__, SessionSpecificSampler.__init__
- Add sphinx.ext.autosummary extension - Create custom class template for detailed docs - Reorganize api.rst with autosummary tables - Each class/function now gets its own page
- Create configuration.rst with full default.yaml embedded - Add documentation for all configuration options - Update index.rst to include configuration page
- Add features section highlighting key capabilities - Include quick start examples for Experiment and DataLoader - Add configuration snippet and documentation links - Add contributing, license, and citation sections
|
Review these changes at https://app.gitnotebooks.com/sensorium-competition/experanto/pull/96 |
There was a problem hiding this comment.
Pull request overview
Adds NumPy-style docstrings and a Sphinx/ReadTheDocs documentation pipeline to generate API reference pages automatically.
Changes:
- Added/expanded NumPy-style docstrings across core modules (datasets, interpolators, experiment, utils, intervals, dataloaders).
- Added Sphinx configuration (autodoc/napoleon/autosummary) plus API/configuration pages and a custom autosummary class template.
- Updated README with features, quick start, and documentation links; ignored generated API docs output in
.gitignore.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| experanto/utils.py | Updates docstrings for utilities and cyclers; minor formatting changes. |
| experanto/intervals.py | Adds docstrings and corrects some return type annotations for interval utilities. |
| experanto/interpolators.py | Adds comprehensive class/method docstrings; minor typing fix for rescale_size. |
| experanto/experiment.py | Adds class/method docstrings for the main Experiment interface. |
| experanto/datasets.py | Adds a full NumPy-style class docstring and method docstrings for ChunkDataset. |
| experanto/dataloaders.py | Adds docstrings and examples for multi-session dataloader helpers. |
| experanto/configs.py | Adds module docstring describing exported default config constants. |
| docs/source/index.rst | Cleans up wording and adds API Reference toctree entries. |
| docs/source/configuration.rst | New docs page describing configuration options and embedding default YAML. |
| docs/source/conf.py | Enables Sphinx extensions and configures autodoc/napoleon/autosummary + mocks. |
| docs/source/api.rst | New autosummary-driven API reference index. |
| docs/source/_templates/custom-class-template.rst | New autosummary template to generate per-class pages with methods/attributes. |
| docs/source/_static/.gitkeep | Keeps _static/ directory tracked. |
| README.md | Adds features, quick start examples, and RTD links. |
| .gitignore | Ignores Sphinx autosummary generated output directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
reneburghardt
left a comment
There was a problem hiding this comment.
Really nice stuff @oliveira-caio
- Add configuration options section to demo_configs.rst - Remove standalone configuration.rst (duplicated content) - Update index.rst to remove configuration from API Reference
…o/experanto into claude/add-docstrings-KhA9Q
- Remove query language from Interpolator base class - Add TimeIntervalInterpolator class docstring with full detail - Minimize all interpolate method docstrings (detail lives in classes) - Add TimeIntervalInterpolator to Interpolator See Also section
…o/experanto into claude/add-docstrings-KhA9Q
schewskone
left a comment
There was a problem hiding this comment.
Cool PR! Thanks @oliveira-caio
Not sure about the TeX formatting inside the code itself.
Can it be used for automated docstrings in readthedocs where it is formatted properly?
| ``global_sampling_rate`` | ||
| Override sampling rate for all modalities. Set to ``null`` to use per-modality rates. |
There was a problem hiding this comment.
Why null and not None in these examples?
| and ``"standardize"`` (z-score normalization). | ||
|
|
||
| ``interpolation`` | ||
| Interpolation settings including ``interpolation_mode`` (``"linear"`` or |
There was a problem hiding this comment.
Maybe mention that this is only for Sequence interpolators
|
|
||
| .. math:: | ||
|
|
||
| y(t) = y_0 \\cdot \\frac{t_1 - t}{t_1 - t_0} + y_1 \\cdot \\frac{t - t_0}{t_1 - t_0}, |
There was a problem hiding this comment.
| y(t) = y_0 \\cdot \\frac{t_1 - t}{t_1 - t_0} + y_1 \\cdot \\frac{t - t_0}{t_1 - t_0}, | |
| y = y0 * (t1 - t) / (t1 - t0) + y1 * (t - t0) / (t1 - t0) |
Markdown does not work here right or is this useful for readthedocs?
There was a problem hiding this comment.
At least locally it works for me
I guess because the mathjax extension was added to readthedocs?! see https://github.com/sensorium-competition/experanto/pull/96/changes#diff-008dcb3426febd767787b1521f1fe33086313b927ea37eaab86df5fa88a51698R27
|
|
||
| y(t) = y_0 \\cdot \\frac{t_1 - t}{t_1 - t_0} + y_1 \\cdot \\frac{t - t_0}{t_1 - t_0}, | ||
|
|
||
| where :math:`t_0` and :math:`t_1` are the surrounding sample times. |
There was a problem hiding this comment.
| where :math:`t_0` and :math:`t_1` are the surrounding sample times. | |
| where t_0 and t_1 are the surrounding sample times. |
|
|
||
| ``transforms`` | ||
| Dictionary of transforms to apply. Supports ``"normalize"`` (0-1 scaling) | ||
| and ``"standardize"`` (z-score normalization). |
There was a problem hiding this comment.
Actually supports also custom transforms, defined as dicts containing key _target_ whose value contains a class + optional arguments as further key-value pairs.
E.g., something like this
"SelectOdorProperties": {
"_target_": "odor_model.dataset_transforms.SelectOdorTrialPropertiesAsModalitiesTransform",
"properties": ["graph"],
}
| Sampling rate in Hz for this modality. | ||
|
|
||
| ``chunk_size`` | ||
| Number of samples per chunk. |
There was a problem hiding this comment.
Not sure myself, but maybe "data points" or "time steps" is better than "samples" here.
|
|
||
| Interpolators load data from a modality folder and map time points to | ||
| data values. Each modality (e.g., screen, responses, eye_tracker, | ||
| treadmill) has a specialized interpolator subclass. |
There was a problem hiding this comment.
I think I still not agree that each modality has a specialized interpolator subclass.
I think we have interpolator subclasses for different temporal representations, e.g. SequenceInterpolator for continuous signals (ScreenInterpolator is basically a special instance of that as images and videos need special handling for efficiency), TimeIntervalInterpolator for bounded intervals and later SpikesInterpolator and EventInterpolator for timestamps.
Summary
Changes
Docstrings
experiment.py: Experiment class, interpolate(), get_valid_range()datasets.py: ChunkDataset class and methodsdataloaders.py: get_multisession_dataloader(), get_multisession_concat_dataloader()interpolators.py: All interpolator classes (Interpolator, SequenceInterpolator, ScreenInterpolator, etc.)intervals.py: TimeInterval class and interval functionsutils.py: LongCycler, ShortCycler, FastSessionDataLoader, SessionBatchSampler, etc.Documentation Structure
README