|
| 1 | +--- |
| 2 | +description: Find deprecated access patterns in code and documentation |
| 3 | +--- |
| 4 | + |
| 5 | +## Reference Document |
| 6 | + |
| 7 | +**Read the authoritative patterns guide first:** |
| 8 | +`docs/developer/UW3_Style_and_Patterns_Guide.qmd` |
| 9 | + |
| 10 | +Key sections: |
| 11 | +- Section 4 "Array and Data Management" - array indexing patterns |
| 12 | +- Section 5 "Context Managers" - deprecated vs current access patterns |
| 13 | +- Section 6 "MPI and Parallel Patterns" - parallel safety |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Search for Legacy Patterns |
| 18 | + |
| 19 | +### Source Code |
| 20 | +```bash |
| 21 | +grep -r "with.*\.access(" src/underworld3/ --include="*.py" |
| 22 | +``` |
| 23 | + |
| 24 | +### Examples |
| 25 | +```bash |
| 26 | +grep -r "with.*\.access(" docs/examples/ --include="*.py" |
| 27 | +grep -r "mesh\.data\[" docs/examples/ --include="*.py" |
| 28 | +``` |
| 29 | + |
| 30 | +### Documentation (markdown, quarto) |
| 31 | +```bash |
| 32 | +grep -r "with.*\.access(" docs/ --include="*.md" --include="*.qmd" |
| 33 | +grep -r "mesh\.data\[" docs/ --include="*.md" --include="*.qmd" |
| 34 | +``` |
| 35 | + |
| 36 | +### Notebooks |
| 37 | +```bash |
| 38 | +find docs -name "*.ipynb" -exec grep -l "\.access(" {} \; |
| 39 | +find docs -name "*.ipynb" -exec grep -l "mesh\.data" {} \; |
| 40 | +``` |
| 41 | + |
| 42 | +### Tests (IMPORTANT: Tests are a source of truth for AI tools) |
| 43 | +```bash |
| 44 | +grep -r "with.*\.access(" tests/ --include="*.py" |
| 45 | +grep -r "mesh\.data\[" tests/ --include="*.py" |
| 46 | +``` |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Pattern Classification |
| 51 | + |
| 52 | +| Pattern | Status | Replacement | |
| 53 | +|---------|--------|-------------| |
| 54 | +| `with mesh.access(var):` | **Deprecated** | Direct: `var.data[...]` | |
| 55 | +| `with swarm.access(var):` | **Deprecated** | Direct: `var.data[...]` | |
| 56 | +| `mesh.data` (coordinates) | **Deprecated** | `mesh.X.coords` | |
| 57 | +| `var.array[:, 0, 0]` | Current | Scalar indexing | |
| 58 | +| `var.array[:, 0, :]` | Current | Vector indexing | |
| 59 | +| `uw.synchronised_array_update()` | Current | Multi-variable batch | |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## Analysis Required |
| 64 | + |
| 65 | +For each occurrence found, classify as: |
| 66 | +- **Safe to remove**: Simple data access, visualization, I/O |
| 67 | +- **Preserve for now**: Solver-critical operations needing further analysis |
| 68 | +- **Already correct**: Part of the access context implementation itself |
| 69 | + |
| 70 | +## Output Format |
| 71 | + |
| 72 | +- Total occurrences by location (src, examples, docs, notebooks, **tests**) |
| 73 | +- Files needing updates grouped by type |
| 74 | +- Priority order: |
| 75 | + 1. User-facing examples (docs/examples) |
| 76 | + 2. **Tests** (source of truth for AI tools writing notebooks) |
| 77 | + 3. Documentation (notebooks, markdown) |
| 78 | + 4. Source code |
| 79 | +- Recommended fixes |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Docstring Health Checks |
| 84 | + |
| 85 | +### Regenerate Inventory |
| 86 | +```bash |
| 87 | +pixi run -e default python scripts/docstring_sweep.py |
| 88 | +``` |
| 89 | + |
| 90 | +### Quick Statistics |
| 91 | +```bash |
| 92 | +# Count items by status in review queue |
| 93 | +grep -c "none" docs/docstrings/review_queue.md || echo "0" |
| 94 | +grep -c "minimal" docs/docstrings/review_queue.md || echo "0" |
| 95 | +grep -c "partial" docs/docstrings/review_queue.md || echo "0" |
| 96 | +grep -c "complete" docs/docstrings/review_queue.md || echo "0" |
| 97 | +``` |
| 98 | + |
| 99 | +### Format Inconsistencies |
| 100 | +```bash |
| 101 | +# Find Markdown math in source (should be RST :math: format) |
| 102 | +grep -rn '\$[^$]*\$' src/underworld3/ --include="*.py" | grep -v "test_" | head -20 |
| 103 | +``` |
| 104 | + |
| 105 | +### Reference |
| 106 | +- Full inventory: `docs/docstrings/review_queue.md` (with NEEDS_* flags) |
| 107 | +- Conversion plan: `docs/plans/docstring-conversion-plan.md` |
| 108 | +- Target format: NumPy/Sphinx with RST math (`:math:`, `.. math::`) |
0 commit comments