# Contributing to lowess
Thank you for your interest in contributing to the `lowess` crate! This document provides guidelines and instructions for contributing.
## Code of Conduct
Be respectful, inclusive, and constructive in all interactions. We're here to build great software together.
## How to Contribute
### Reporting Bugs
If you find a bug, please create an issue on GitHub with:
- A clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Your environment (OS, Rust version, etc.)
- Minimal code example if applicable
### Suggesting Features
Feature requests are welcome! Please:
- Check if a similar request already exists
- Explain the use case and benefits
- Provide examples of how it would work
### Pull Requests
1. **Fork the repository** and create a new branch from `develop`
2. **Make your changes** with clear, focused commits
3. **Add tests** for new functionality
4. **Update documentation** as needed
5. **Run the full test suite** before submitting
6. **Submit a pull request** with a clear description
## Development Setup
```bash
# Clone your fork
git clone https://github.com/YOUR_USERNAME/lowess.git
cd lowess
# Create a development branch
git checkout -b feature/my-feature
# Build and test
cargo build
cargo test
cargo clippy
cargo fmt --check
```
## Testing
### Running Tests
```bash
# Unit tests
cargo test
# Integration tests
cargo test --test integration_tests
# All tests with output
cargo test -- --nocapture
# Specific test
cargo test test_basic_lowess
```
### Writing Tests
- Add tests in `tests/`
- Use descriptive test names
- Test edge cases and error conditions
- Use `approx` crate for floating-point comparisons
Example:
```rust
#[test]
fn test_my_feature() {
let x = vec![1.0, 2.0, 3.0];
let y = vec![1.0, 2.0, 3.0];
let result = lowess(&x, &y, 0.5, 2, None).unwrap();
assert_eq!(result.x.len(), 3);
}
```
## Code Style
### Formatting
We use `rustfmt` with default settings:
```bash
cargo fmt
```
### Linting
We use `clippy` with strict settings:
```bash
cargo clippy -- -D warnings
```
### Documentation
- All public items must have doc comments (`///`)
- Include examples in doc comments when helpful
- Use proper Markdown formatting
- Document panics, errors, and edge cases
Example:
```rust
/// Performs LOWESS smoothing on the given data.
///
/// # Arguments
/// * `x` - Input x-values
/// * `y` - Input y-values
///
/// # Returns
/// Smoothed y-values
///
/// # Errors
/// Returns `LowessError::EmptyInput` if inputs are empty
///
/// # Example
/// ```
/// use lowess::lowess;
/// let x = vec![1.0, 2.0, 3.0];
/// let y = vec![1.0, 2.0, 3.0];
/// let result = lowess(&x, &y, 0.5, 2, None).unwrap();
/// ```
pub fn lowess<T>(...) -> Result<LowessResult<T>> {
// ...
}
```
## Commit Messages
Follow conventional commits format:
```
type(scope): brief description
Longer explanation if needed
Fixes #123
```
Types:
- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation changes
- `style`: Formatting, missing semicolons, etc.
- `refactor`: Code restructuring
- `test`: Adding tests
- `chore`: Maintenance tasks
Examples:
- `feat(api): add support for weighted LOWESS`
- `fix(core): correct robustness weight calculation`
- `docs(readme): add performance benchmarks`
## Performance
For performance-critical changes:
- Run benchmarks before and after
- Document performance characteristics
- Consider algorithmic complexity
```bash
cargo bench
```
## Adding Dependencies
Keep dependencies minimal. Before adding a new dependency:
1. Check if it's necessary
2. Verify it's well-maintained
3. Check its dependency tree
4. Discuss in an issue first for non-trivial additions
## Release Process
Maintainers will:
1. Update version in `Cargo.toml`
2. Update `CHANGELOG.md`
3. Create a git tag
4. Publish to crates.io
5. Create a GitHub release
## Questions?
Feel free to:
- Open an issue for questions
- Start a discussion on GitHub
- Email the maintainer: thisisamirv@gmail.com
## License
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing! 🎉