A Python Units Wizard that streamlines work with physical quantities.
This file defines how automated agents and human contributors must work with the PyUnitWizard repository.
It serves as a guide for consistent, transparent, and safe collaboration between humans and automated systems.
PyUnitWizard is a Python library that standardizes and simplifies the handling of physical units across different unit systems.
It acts as a bridge between libraries such as pint, unyt, openmm.unit, and astropy.units, allowing seamless conversions and interoperability.
Design principles:
- Composability: small, reusable components.
- Extensibility: easy to add new unit systems or APIs.
- Robustness: strict type checking and dimensional consistency.
By integrating PyUnitWizard, scientific libraries can let users choose how units are represented and handled without changing their workflows. This ensures that outputs can be used as inputs in other tools regardless of the unit system, making scientific pipelines compatible, flexible, and interoperable.
Main directories and files:
| Path | Description |
|---|---|
pyunitwizard/ |
Core source code. |
tests/ |
Unit and integration tests. |
devtools/ |
Environment, build, and maintenance tools. |
docs/ |
Documentation sources (Sphinx). |
examples/ |
Example integrations showing how to embed PyUnitWizard into other scientific Python libraries. |
sandbox/ |
Experimental code and notes. |
logos/ |
Branding assets. |
CODE_OF_CONDUCT.md |
Community standards. |
AGENTS.md |
Agent interaction rules (this file). |
README.md |
Quick start and overview. |
LICENSE |
License information. |
MANIFEST.in |
Packaging manifest file. |
pyproject.toml |
Build system configuration. |
pytest.ini |
Pytest configuration. |
setup.cfg |
Setup tools configuration. |
Additional AGENTS.md files may exist in submodules with specialized instructions.
- Keep PRs small and focused.
- Use English for all code, comments, PRs, issues, and docs.
- Always include or update tests and documentation for user-visible changes.
- Follow existing patterns and maintain readability.
- Avoid unnecessary cleverness — clarity first.
- Follow PEP 8.
- Tools:
black(formatting),isort(imports),flake8(linting),mypy(type checking). - Prefer short, modular functions.
- Use explicit, descriptive names.
- Run linting and type checks before committing.
| Element | Convention | Example |
|---|---|---|
| Variables / functions | snake_case |
convert_units() |
| Classes | PascalCase |
UnitSystem |
| Private members | Prefix with _ |
_parse_symbol() |
| Boolean-returning | Suffix _is / _has |
is_valid(), has_units() |
- Use NumPy style.
- Each public symbol must include Parameters, Returns, Raises, and Examples when applicable.
- Annotate all public functions (PEP 484).
- Use
Optional[T]for nullable types. - Use
LiteralorEnumfor restricted values.
- Explain why, not just what.
- Keep comments up to date.
- Prefer brief, focused notes.
- Tags:
TODO,FIXME,NOTE,WARNING(with author/date if long-term).
- Use custom exceptions in
exceptions.pyfor domain-specific errors. - Never use bare
except:clauses. - Provide clear and informative error messages.
- Use
loggingfor runtime messages. - Use
_private/warningsfor non-critical issues or deprecations.
- Use only dependencies listed in
devtools/conda-envs/development_env.yaml. - Avoid deprecated or unmaintained packages.
- Regularly verify that dependencies are available, necessary, and pertinent.
- Check dependencies periodically using tools such as
safetyorbandit. - Never commit secrets, credentials, or environment variables.
- Avoid hardcoding sensitive information in code or logs.
- Do not report or share secrets, credentials, or environment variables in issues, PRs, or any communication channel.
- All public functions and modules must have tests under
tests/. - Use
pytestfor test execution. - Run
pytest tests/before each PR. - Test both success and failure cases.
- Prefer unit tests for small functions and integration tests for workflows.
- Keep tests independent and reproducible.
- For new features: write or update unit tests first, then implement the feature until all tests pass (“code to green”).
- For regressions: add a failing test that reproduces the bug, then fix it.
- For UI or state-based modules: prefer component tests that validate observable changes.
- Written in Markdown or MyST (for Sphinx).
- Each public module must include examples and docstrings.
- Update documentation after API or behavior changes.
- Validate generated docs before merging (
make html). - Do not include private or experimental code in public docs.
Use the conventional format:
<type>(<scope>): <short description>
Examples:
feat(core): add converter for astropy unitsfix(tests): correct numpy array comparisondocs(readme): improve quick-start example
Keep commits atomic, small, and meaningful.
- Run all tests before submitting.
- Ensure lint/type checks pass.
- Keep PRs under 300 lines of diff when possible.
- Include context and motivation in the PR body.
- Link related issues with
Fixes #<id>orCloses #<id>.
Checklist:
- ✅ All tests and checks pass.
- ✅ Code reviewed or self-reviewed.
- ✅ Docs updated if behavior changed.
- ✅ No debug or leftover code.
These rules apply to automated agents (GitHub Actions, Copilot Agents, CI bots, etc.) collaborating on this repository.
- Always wait for terminal commands to complete before proceeding.
- Do not modify code outside the assigned scope.
- Prefer proposing changes via PR rather than direct commits to
main. - Ask for clarification or open a draft PR if unsure.
- Never overwrite human work or documentation without explicit approval.
- When stuck, ask a clarifying question, propose a short plan, or open a draft PR with notes — do not push large speculative changes without confirmation.
When referencing files or terminal outputs in responses, use the following citation style:
- File citations:
【F:<path>†L<start>-L<end>】 - Terminal citations:
【<chunk_id>†L<start>-L<end>】
Only cite relevant, contentful lines — never blank lines.
If referencing code changes or test results in PR summaries, prefer file citations; use terminal citations only when output verification is required.
- Commit using
git(no untracked changes). - Fix pre-commit issues before retrying.
- Do not amend existing commits; create new ones.
- Confirm with
git statusbefore finishing.
- Follow test-first development: add or update tests before writing new code.
- For bug fixes, add a failing test first, then implement the fix.
- Do not skip tests unless justified in the PR.
This section defines automated consistency checks to be performed by AI or CI agents before merging changes.
To be extended in future versions, it may include:
- Verification of documentation coverage.
- Automatic code style and dependency audits.
- Validation of cross-repo synchronization for shared components.
Allowed without prompt:
- Running linters, formatters, or test suites.
- Generating documentation locally.
- Checking dependency status.
Ask before doing:
- Committing code or modifying configuration.
- Running destructive commands (e.g., deleting branches or files).
- Editing documentation or CI pipelines.
- Updating build/test commands, contribution guidelines, or security considerations.
- Changing commit message conventions or PR workflows.
- After any change, verify if documentation, examples, or tests must be updated.
- After any change, verify if any
AGENTS.mdorREADME.mdneed to be updated for consistency. - Regularly review CI configurations for dependency or policy drift.
- Keep this file synchronized across UIBCDF projects when possible.
Last updated: November 2025
These guides are required reading for anyone developing this library. They describe how external tools must be used here.
SMONITOR_GUIDE.md— Required guide for SMonitor integration and diagnostics.