Contributing

This guide explains how to contribute to EZStitcher.

Setting Up Development Environment

  1. Fork the repository on GitHub

  2. Clone your fork:

    git clone https://github.com/your-username/ezstitcher.git
    cd ezstitcher
    
  3. Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # Linux/macOS
    # or
    .venv\Scripts\activate     # Windows
    
  4. Install development dependencies:

    pip install -e ".[dev]"
    
  5. Install pre-commit hooks:

    pre-commit install
    

Making Changes

  1. Create a new branch for your changes:

    git checkout -b feature/your-feature-name
    
  2. Make your changes to the codebase

  3. Run tests to ensure your changes don’t break existing functionality:

    pytest
    
  4. Run linters to ensure your code follows the project’s style guidelines:

    flake8
    black .
    isort .
    
  5. Commit your changes with a descriptive commit message:

    git add .
    git commit -m "Add feature: your feature description"
    
  6. Push your changes to your fork:

    git push origin feature/your-feature-name
    
  7. Create a pull request from your fork to the main repository

Code Style

EZStitcher follows these code style guidelines:

  • PEP 8: Follow the PEP 8 style guide

  • Black: Use Black for code formatting

  • isort: Use isort for import sorting

  • Docstrings: Use Google-style docstrings

  • Type Hints: Use type hints for function and method signatures

Example of a well-formatted function:

def process_image(image: np.ndarray, sigma: float = 1.0) -> np.ndarray:
    """
    Process an image with a Gaussian filter.

    Args:
        image: Input image
        sigma: Standard deviation for Gaussian kernel

    Returns:
        Processed image
    """
    # Convert to float for processing
    image_float = image.astype(np.float32)

    # Apply Gaussian filter
    processed = ndimage.gaussian_filter(image_float, sigma=sigma)

    # Convert back to original dtype
    return processed.astype(image.dtype)

Documentation

All code contributions should include documentation:

  1. Add docstrings to all modules, classes, and functions:

    def some_function(param1, param2):
        """
        Brief description of the function.
    
        Args:
            param1 (type): Description of param1
            param2 (type): Description of param2
    
        Returns:
            type: Description of return value
    
        Raises:
            ExceptionType: When and why this exception is raised
        """
        # Function implementation
    
  2. Update the documentation if you change existing functionality:

    cd docs
    make html
    
  3. Add examples for new features:

    # Example usage of new feature
    from ezstitcher.core import new_feature
    
    result = new_feature(input_data)
    print(result)
    

Testing

All code contributions should include tests:

  1. Add unit tests for new functionality:

    def test_new_feature():
        """Test the new feature."""
        # Test implementation
        result = new_feature(input_data)
        assert result == expected_result
    
  2. Add integration tests for new components:

    def test_new_component_integration():
        """Test the new component in the full pipeline."""
        # Test implementation
        pipeline = Pipeline(new_component)
        result = pipeline.run(input_data)
        assert result == expected_result
    
  3. Run all tests before submitting a pull request:

    pytest
    

Pull Request Process

  1. Ensure all tests pass on your local machine

  2. Update the documentation to reflect your changes

  3. Document your changes thoroughly in code and documentation

  4. Submit your pull request with a clear description of the changes

  5. Address any feedback from the code review

  6. Wait for approval from a maintainer

Release Process

  1. Update version number in ezstitcher/__init__.py

  2. Prepare a detailed changelog for the release

  3. Create and push a new tag:

    git tag -a v{version} -m "Release version {version}"
    git push origin v{version}
    
  4. Build and upload the package to PyPI manually:

    # Build the package
    python -m build
    
    # Upload to PyPI (you'll need your PyPI token)
    python -m twine upload dist/*
    

    Note: Make sure you have build and twine installed: pip install build twine

Code of Conduct

Please follow these guidelines when contributing to EZStitcher:

  1. Be respectful of other contributors

  2. Be constructive in your feedback

  3. Be patient with new contributors

  4. Be inclusive and welcoming to all

  5. Be collaborative and work together to solve problems