-
Notifications
You must be signed in to change notification settings - Fork 0
Add Copilot instructions for repository context #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,150 @@ | ||||||||
| # Copilot Instructions for gradient-free-optimizer | ||||||||
|
|
||||||||
| ## Project Overview | ||||||||
|
|
||||||||
| This is a Python project for gradient-free optimization with molecular geometry utilities. The main module `molecule.py` provides utilities for: | ||||||||
| - Reading XYZ files | ||||||||
| - Writing Turbomole `coord` files (with Angstrom to Bohr conversion) | ||||||||
| - Converting between XYZ and Z-matrix representations using Open Babel (`obabel`) | ||||||||
| - Inserting molecular coordinates into templates | ||||||||
|
|
||||||||
| ## Python Version Support | ||||||||
|
|
||||||||
| - **Supported versions**: Python 3.9, 3.10, and 3.11 | ||||||||
| - Always ensure code is compatible with all supported versions | ||||||||
| - CI runs tests against all three versions | ||||||||
|
|
||||||||
| ## Testing Framework | ||||||||
|
|
||||||||
| ### Test Structure | ||||||||
| - **Framework**: pytest | ||||||||
| - **Test location**: `tests/` directory | ||||||||
| - **Test files**: Use `test_*.py` naming convention | ||||||||
| - **Test fixtures**: Defined in `tests/conftest.py` | ||||||||
|
|
||||||||
| ### Running Tests | ||||||||
| ```bash | ||||||||
| # Full test suite | ||||||||
| pytest -q | ||||||||
|
|
||||||||
| # Single test file | ||||||||
| pytest tests/test_molecule.py -q | ||||||||
|
|
||||||||
| # Specific test | ||||||||
| pytest tests/test_molecule.py::test_write_coord_from_xyz -q | ||||||||
| ``` | ||||||||
|
|
||||||||
| ### Test Conventions | ||||||||
| - Use `pytest.approx()` for floating-point comparisons | ||||||||
| - Use `tmp_path` fixture for temporary file operations | ||||||||
| - Mock `subprocess.run` when testing behavior without external dependencies (e.g., `obabel`) | ||||||||
| - Tests should not require Open Babel to be installed; mock subprocess calls when needed | ||||||||
|
|
||||||||
| ## Code Style and Conventions | ||||||||
|
|
||||||||
| ### General Guidelines | ||||||||
| - Follow PEP 8 style guidelines | ||||||||
| - Use type hints where appropriate (as seen in `molecule.py`) | ||||||||
| - Include docstrings for classes and public methods | ||||||||
| - Use descriptive variable names | ||||||||
|
|
||||||||
| ### Constants | ||||||||
| - Define constants at module level in UPPER_CASE (e.g., `ANGSTROM_TO_BOHR`) | ||||||||
|
|
||||||||
| ### Error Handling | ||||||||
| - Define custom exceptions for specific error cases (e.g., `ObabelNotFoundError`, `ObabelError`) | ||||||||
| - Provide informative error messages | ||||||||
|
|
||||||||
| ### Documentation | ||||||||
| - Module-level docstrings should describe the module's purpose and main functionality | ||||||||
| - Class docstrings should include: | ||||||||
| - Description of the class purpose | ||||||||
| - Important attributes | ||||||||
| - Usage notes | ||||||||
| - Use triple-quoted strings with proper formatting | ||||||||
|
|
||||||||
| ## Dependencies | ||||||||
|
|
||||||||
| ### Runtime Dependencies | ||||||||
| - Python standard library (primary) | ||||||||
| - `numpy` (used in some computations) | ||||||||
| - External tool: `obabel` (optional, for format conversions) | ||||||||
|
|
||||||||
| ### Development Dependencies | ||||||||
| - `pytest` for testing | ||||||||
| - No additional linting tools currently configured | ||||||||
|
|
||||||||
| ### Virtual Environment | ||||||||
| Recommended setup: | ||||||||
| ```bash | ||||||||
| python3 -m venv .venv | ||||||||
| source .venv/bin/activate | ||||||||
| pip install -U pip | ||||||||
| pip install pytest numpy | ||||||||
| ``` | ||||||||
|
|
||||||||
| ## Project Structure | ||||||||
|
|
||||||||
| ``` | ||||||||
| . | ||||||||
| ├── .github/ | ||||||||
| │ └── workflows/ # CI/CD workflows | ||||||||
| ├── tests/ # Test files | ||||||||
| │ ├── conftest.py # Pytest fixtures | ||||||||
| │ ├── test_molecule.py # Molecule class tests | ||||||||
| │ └── test_kabsch.py # Kabsch algorithm tests | ||||||||
| ├── molecule.py # Main molecule utilities module | ||||||||
| ├── main.py # Sample script/entry point | ||||||||
| └── README.md # Project documentation | ||||||||
| ``` | ||||||||
|
Comment on lines
+86
to
+99
|
||||||||
|
|
||||||||
| ## CI/CD | ||||||||
|
|
||||||||
| ### GitHub Actions | ||||||||
| - **Workflow file**: `.github/workflows/python-pytest.yml` | ||||||||
| - **Trigger**: Pushes and PRs to `main` or `master` branches | ||||||||
| - **Matrix testing**: Runs on Python 3.9, 3.10, and 3.11 | ||||||||
| - **Steps**: | ||||||||
| 1. Checkout code | ||||||||
| 2. Set up Python | ||||||||
| 3. Cache pip dependencies | ||||||||
| 4. Install dependencies (pytest and numpy) | ||||||||
| 5. Run pytest with `-q -r a` flags | ||||||||
|
|
||||||||
| ### CI Requirements | ||||||||
| - All tests must pass on all supported Python versions | ||||||||
| - No external dependencies (like Open Babel) required in CI | ||||||||
|
|
||||||||
|
Comment on lines
+101
to
+117
|
||||||||
| ## Special Considerations | ||||||||
|
|
||||||||
| ### Unit Conversions | ||||||||
| - Coordinates are stored in Angstrom internally | ||||||||
| - Turbomole output uses Bohr: `1 Angstrom = 1.889725988579 Bohr` | ||||||||
| - Use `ANGSTROM_TO_BOHR` constant for conversions | ||||||||
|
|
||||||||
| ### External Tool Integration | ||||||||
| - `obabel` is called via `subprocess` for format conversions | ||||||||
| - Code should gracefully handle missing `obabel` installation | ||||||||
| - Raise `ObabelNotFoundError` when `obabel` is not available | ||||||||
| - Tests should mock subprocess calls to avoid dependency on `obabel` | ||||||||
|
|
||||||||
| ### Z-matrix Support | ||||||||
| - Z-matrix functionality includes both parsing and generation | ||||||||
| - Coordinate representations (XYZ and Z-matrix) must be kept consistent | ||||||||
| - Pure Python implementation available as fallback | ||||||||
|
|
||||||||
|
Comment on lines
+134
to
+135
|
||||||||
| - Pure Python implementation available as fallback | |
| - Z-matrix parsing (`from_zmatrix()`) is implemented in pure Python | |
| - Z-matrix generation (`to_zmatrix()`) currently requires `obabel` and raises `ObabelNotFoundError` if it is not available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stated supported Python versions (3.9–3.11) don’t match the repo’s CI configuration:
.github/workflows/pytest.ymlcurrently runs against Python 3.8 as well. Update these instructions (or the CI matrix) so the documented support and actual test matrix are consistent.