Thank you for your interest in contributing to neutronbraggedge! This document provides guidelines for contributing to the project.
- Python 3.11 or 3.12
- Pixi for environment management
-
Clone the repository:
git clone https://github.com/ornlneutronimaging/BraggEdge.git cd BraggEdge -
Install dependencies with Pixi:
pixi install
-
Install pre-commit hooks:
pixi run pre-commit-install
-
Verify your setup:
pixi run test
We use a three-branch workflow:
next: Development branch (default). All PRs should target this branch.qa: Quality assurance branch for pre-release testing.main: Stable release branch. Only receives merges fromqa.
-
Create a feature branch from
next:git checkout next git pull origin next git checkout -b feature/your-feature-name
-
Make your changes and commit:
git add <files> git commit -m "Brief description of changes"
-
Push and create a pull request:
git push -u origin feature/your-feature-name
-
Open a PR targeting the
nextbranch.
We use Ruff for linting and formatting.
- Line length: 120 characters
- Quotes: Double quotes
- Imports: Sorted with isort-compatible ordering
pixi run lint # Check for issues
pixi run format # Auto-format codePre-commit hooks run automatically on commit. To run manually:
pixi run pre-commitpixi run test # Full suite with coverage
pixi run test-fast # Quick run (stops on first failure)- Place tests in
tests/mirroring the source structure - Use
*_test.pynaming pattern - Use pytest fixtures for common setup
- Use
pytest.approx()for floating-point comparisons
Example:
import pytest
from neutronbraggedge.braggedge import BraggEdge
class TestBraggEdge:
def test_calculates_d_spacing_correctly(self):
"""d_spacing values should match expected crystallographic values."""
handler = BraggEdge(material="Fe", number_of_bragg_edges=4)
d_spacing = handler.d_spacing["Fe"]
assert d_spacing[0] == pytest.approx(2.0269, abs=0.001)Place test data files in tests/data/. Reference them using the get_data_file fixture from conftest.py.
- All tests pass (
pixi run test) - Pre-commit hooks pass (
pixi run pre-commit) - New code has appropriate test coverage
- Docstrings are updated for public APIs
Include:
- Summary: What the PR does
- Motivation: Why this change is needed
- Test plan: How to verify the changes work
- Automated CI checks must pass
- At least one maintainer approval required
- Address review feedback promptly
- Squash commits if requested
Write clear, concise commit messages:
Short summary (50 chars or less)
Optional longer description explaining the motivation
for the change. Wrap at 72 characters.
- Bullet points are fine
- Use present tense ("Add feature" not "Added feature")
Include:
- Python version and OS
- Steps to reproduce
- Expected vs actual behavior
- Error messages and tracebacks
Include:
- Use case description
- Proposed solution (if any)
- Alternatives considered
- Open an issue for general questions
- Check existing issues and documentation first
- Tag maintainers if urgent
By contributing, you agree that your contributions will be licensed under the BSD-3-Clause License.