Contributing¶
Thank you for your interest in contributing to neurospatial! This guide will help you get started.
Getting Started¶
Development Setup¶
- Fork the repository on GitHub
- Clone your fork locally:
- Install development dependencies:
- Set up pre-commit hooks:
Development Workflow¶
This project uses uv for package management. Always prefix commands with uv run:
# Run tests
uv run pytest
# Run specific test
uv run pytest tests/test_environment.py::test_name -v
# Check code quality
uv run ruff check .
# Format code
uv run ruff format .
# Type check (optional)
uv run mypy src/neurospatial
Code Standards¶
Python Style¶
- Follow PEP 8 (enforced by ruff)
- Use type hints where practical
- Write descriptive variable names
- Keep functions focused and small
Docstring Format¶
CRITICAL: All docstrings MUST follow NumPy docstring format:
def function_name(param1, param2):
"""
Short one-line summary ending with a period.
Longer description if needed.
Parameters
----------
param1 : type
Description of param1.
param2 : type, optional
Description of param2. Default is None.
Returns
-------
return_type
Description of return value.
Raises
------
ValueError
When this error occurs.
Examples
--------
>>> result = function_name(1, 2)
>>> print(result)
3
"""
See NumPy Docstring Guide for details.
Commit Messages¶
Use Conventional Commits:
feat(environment): add .info() method
fix(regions): correct area calculation for polygons
docs(quickstart): update installation instructions
test(layout): add tests for hexagonal layout
chore(deps): update numpy to 2.3.4
Testing¶
Writing Tests¶
- Place tests in
tests/directory - Mirror source structure:
src/neurospatial/foo.py→tests/test_foo.py - Use descriptive test names:
test_environment_from_samples_creates_bins() - Use pytest fixtures from
tests/conftest.py
Example test:
def test_environment_bin_at_maps_points_correctly():
"""Test that bin_at correctly maps points to bin indices."""
env = Environment.from_samples(sample_data, bin_size=2.0)
points = np.array([[10.0, 10.0]])
bin_idx = env.bin_at(points)
assert bin_idx.shape == (1,)
assert 0 <= bin_idx[0] < env.n_bins
Running Tests¶
# All tests
uv run pytest
# Specific test file
uv run pytest tests/test_environment.py
# With coverage
uv run pytest --cov=src/neurospatial
# Verbose output
uv run pytest -v
# Stop at first failure
uv run pytest -x
Pull Request Process¶
Before Submitting¶
- Run all tests:
uv run pytest - Check code quality:
uv run ruff check . && uv run ruff format . - Update documentation: Add/update docstrings and docs pages
- Add tests: Ensure new code has test coverage
- Update CHANGELOG.md: Add entry under "Unreleased"
Submitting¶
- Create a feature branch:
-
Make your changes with clear commit messages
-
Push to your fork:
- Open a Pull Request on GitHub
PR Description¶
Include in your PR description:
- Summary: What does this PR do?
- Motivation: Why is this change needed?
- Testing: How was this tested?
- Breaking Changes: Any API changes?
- Related Issues: Link to related issues
Example:
## Summary
Adds `.info()` method to Environment class for printing summary statistics.
## Motivation
Users frequently need to inspect environment properties. This provides
a convenient way to see all key information at once.
## Testing
- Added tests in `test_environment.py`
- Manually tested with various environment types
- All existing tests pass
## Breaking Changes
None
## Related Issues
Closes #42
Documentation¶
Building Documentation¶
# Install docs dependencies
uv sync --extra docs
# Serve locally
uv run mkdocs serve
# Build static site
uv run mkdocs build
Documentation is at https://edeno.github.io/neurospatial/
Adding Documentation¶
- New features: Update relevant user guide pages
- API changes: Docstrings are auto-generated
- Examples: Add Jupyter notebooks to
examples/
Release Process¶
(For maintainers)
- Update version in
pyproject.toml - Update
CHANGELOG.md - Create git tag:
git tag v0.2.0 - Push tag:
git push origin v0.2.0 - GitHub Actions handles PyPI release
Getting Help¶
- Questions: Open a GitHub Discussion
- Bugs: Open a GitHub Issue
- Contact: Email eric.denovellis@ucsf.edu
Code of Conduct¶
- Be respectful and inclusive
- Focus on constructive feedback
- Help create a welcoming environment
Recognition¶
Contributors will be acknowledged in:
- CHANGELOG.md
- GitHub contributors page
- Future publications using neurospatial
Thank you for contributing to neurospatial!