First off, thank you for considering contributing to Calculus Calculator! It's people like you that make this project such a great tool for the mathematics community.
- Code of Conduct
- How Can I Contribute?
- Getting Started
- Development Process
- Style Guidelines
- Commit Guidelines
- Pull Request Process
- Testing Guidelines
We pledge to make participation in our project a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to a positive environment:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior:
- The use of sexualized language or imagery
- Trolling, insulting/derogatory comments, and personal attacks
- Public or private harassment
- Publishing others' private information without permission
- Other conduct which could reasonably be considered inappropriate
Before creating bug reports, please check the existing issues to avoid duplicates. When creating a bug report, include as many details as possible:
Bug Report Template:
**Description:**
A clear description of the bug.
**Steps to Reproduce:**
1. Step one
2. Step two
3. Step three
**Expected Behavior:**
What you expected to happen.
**Actual Behavior:**
What actually happened.
**Environment:**
- OS: [e.g., Windows 10, macOS 12, Ubuntu 22.04]
- Python Version: [e.g., 3.10.5]
- Calculator Version: [e.g., 1.0.0]
**Additional Context:**
Any other relevant information.Feature requests are welcome! Please provide:
- Clear description of the feature
- Use cases explaining why it's needed
- Examples of how it would work
- Alternatives you've considered
We love code contributions! Here's how to get started:
# Fork the repository on GitHub
# Then clone your fork
git clone https://github.com/YOUR_USERNAME/Calculus-Calculator.git
cd Calculus-Calculator# Create a virtual environment (recommended)
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install development dependencies
pip install pytest pytest-cov flake8 black mypy# Create a new branch for your feature or bugfix
git checkout -b feature/your-feature-name
# or
git checkout -b bugfix/issue-number-description- Write clean, readable code
- Follow the existing code style
- Add comments for complex logic
- Update documentation as needed
All new features must include tests:
# tests/test_your_feature.py
import pytest
from calculator import CalculusCalculator
def test_your_feature():
"""Test description."""
calc = CalculusCalculator()
result = calc.calculate("your_expression")
assert result['success'] == True
assert result['result'] == "expected_output"
def test_your_feature_edge_case():
"""Test edge case."""
calc = CalculusCalculator()
result = calc.calculate("edge_case_expression")
assert result['success'] == False
assert "error" in result# Run all tests
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ --cov=. --cov-report=html
# Run specific test file
python -m pytest tests/test_your_feature.py# Format code with Black
black .
# Check style with flake8
flake8 . --max-line-length=100
# Type checking with mypy
mypy calculator.pyWe follow PEP 8 with some modifications:
- Line length: Maximum 100 characters (not 79)
- Indentation: 4 spaces (no tabs)
- Quotes: Prefer double quotes for strings
- Imports: Organized in three groups (standard library, third-party, local)
"""
Module docstring describing the module's purpose.
"""
import standard_library
import third_party
from local_module import something
class MyClass:
"""Class docstring."""
def __init__(self):
"""Initialize the class."""
self.attribute = None
def my_method(self, param: str) -> bool:
"""
Method docstring.
Args:
param (str): Parameter description
Returns:
bool: Return value description
"""
return True
def my_function(arg1: int, arg2: str) -> str:
"""
Function docstring.
Args:
arg1 (int): First argument
arg2 (str): Second argument
Returns:
str: Return value
"""
return f"{arg1}: {arg2}"- Docstrings: Use Google-style docstrings
- Comments: Explain why, not what
- Type hints: Use type annotations for function parameters and returns
- README: Update if adding features or changing behavior
Use conventional commit messages:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Examples:
feat(derivatives): Add support for hyperbolic functions
Implement sinh, cosh, and tanh derivatives with corresponding
tests and documentation updates.
Closes #123
fix(parser): Handle empty expressions correctly
Previously, empty expressions would cause a crash. Now they
return a proper error message.
Fixes #456
- Atomic commits: One logical change per commit
- Clear messages: Explain what and why
- Test before commit: Ensure tests pass
- Sign commits: Use
git commit -sfor sign-off
- Code follows style guidelines
- Tests added for new features
- All tests pass
- Documentation updated
- Commit messages follow guidelines
- Branch is up to date with main
-
Push to your fork
git push origin feature/your-feature-name
-
Create Pull Request
- Go to the original repository
- Click "New Pull Request"
- Select your branch
- Fill in the PR template
-
PR Description Template
## Description Brief description of changes ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Documentation update ## Testing - [ ] Tests added/updated - [ ] All tests pass - [ ] Manual testing completed ## Checklist - [ ] Code follows style guidelines - [ ] Documentation updated - [ ] No new warnings - [ ] Commit messages follow guidelines ## Related Issues Closes #123
- Respond to feedback: Address review comments promptly
- Update PR: Push additional commits as needed
- Be patient: Maintainers will review when available
- Stay engaged: Participate in discussions
# tests/test_module.py
import pytest
from your_module import YourClass
class TestYourClass:
"""Test suite for YourClass."""
@pytest.fixture
def instance(self):
"""Create instance for testing."""
return YourClass()
def test_basic_functionality(self, instance):
"""Test basic functionality."""
result = instance.method()
assert result == expected_value
def test_edge_case(self, instance):
"""Test edge case."""
with pytest.raises(ValueError):
instance.method(invalid_input)
@pytest.mark.parametrize("input,expected", [
(1, 2),
(2, 4),
(3, 6),
])
def test_multiple_inputs(self, instance, input, expected):
"""Test with multiple inputs."""
result = instance.method(input)
assert result == expected- Minimum coverage: 80%
- Critical code: 100% coverage for core functionality
- Edge cases: Test boundary conditions
- Error handling: Test error scenarios
# Run all tests with coverage
python -m pytest tests/ --cov=. --cov-report=html --cov-report=term
# View coverage report
open htmlcov/index.html # macOS
xdg-open htmlcov/index.html # Linux
start htmlcov/index.html # WindowsIf you have questions about contributing:
- Check Documentation: Review README and inline comments
- Search Issues: Look for similar questions
- Ask in Discussions: Start a discussion on GitHub
- Contact Maintainers: Reach out directly if needed
Contributors will be:
- Listed in CONTRIBUTORS.md
- Mentioned in release notes
- Credited in commit messages
- Appreciated by the community!
Your contributions make this project better for everyone. Thank you for being part of the Calculus Calculator community!
Happy coding! 🧮✨