|
| 1 | + |
| 2 | +# Copilot Repository-Wide Custom Instructions |
| 3 | + |
| 4 | +- This repository contains applied mathematics models, simulations, and educational content. |
| 5 | +- You must be rigorous above all else. Ask for pdf or references if needed, and cite sources when possible using the tex/references.bib file. |
| 6 | +- When generating code, prefer clear, well-documented Python and Quarto files. |
| 7 | +- Use existing project structure and naming conventions. |
| 8 | +- Validate changes with tests or example runs when possible. |
| 9 | +- For new features, follow the modular organization in the amlab/ directory. |
| 10 | +- For notebooks, use networkx, numpy, matplotlib, and other scientific libraries as needed. |
| 11 | +- When editing Quarto files, preserve formatting and code chunk structure. |
| 12 | +- Always check requirements.txt and setup.py for dependencies. |
| 13 | +- Prefer reproducible, minimal examples for demos and tutorials. |
| 14 | +- Use Markdown formatting for documentation and comments. |
| 15 | + |
| 16 | +## Guidance for Hints and Templates |
| 17 | + |
| 18 | +- When writing guided exercises or templates, use the following conventions: |
| 19 | + - Provide clear, concise hints as comments or Markdown callouts (e.g., callout-tip, callout-note). |
| 20 | + - For blank code, use `# TODO:` comments to indicate what the user should implement. |
| 21 | + - Show solved examples after the blank template, using a callout or a separate code chunk. |
| 22 | + - When writing functions, include docstrings and parameter explanations. |
| 23 | + - Validate code with simple checks (e.g., print statements or assertions). |
| 24 | + - Use Quarto code chunk options to control output (e.g., echo, message, warning). |
| 25 | + - Reference other files or sections for context and further reading. |
| 26 | + |
| 27 | +## Example Template |
| 28 | + |
| 29 | +```python |
| 30 | +def initialize_particles(num_boids, box_size): |
| 31 | + # Random initial theta, shape (N) |
| 32 | + theta = # TODO |
| 33 | + |
| 34 | + # Random initial x, y - shape (2, N) |
| 35 | + xy = # TODO |
| 36 | + return xy, theta |
| 37 | +``` |
| 38 | + |
| 39 | +## Example Hint |
| 40 | + |
| 41 | +Below the fill-in-the-blank template, you can provide a hint in a callout: |
| 42 | + |
| 43 | +::: {.callout-tip collapse="true"} |
| 44 | +## Solved: Initialization (click to expand) |
| 45 | + |
| 46 | +```python |
| 47 | +def initialize_particles(num_boids, box_size): |
| 48 | + theta = np.random.uniform(0, 2 * np.pi, num_boids) |
| 49 | + xy = np.random.uniform(0, box_size, (2, num_boids)) |
| 50 | + return xy, theta |
| 51 | +``` |
| 52 | +::: |
| 53 | + |
| 54 | +Hints can also be provided as questions or notes: |
| 55 | + |
| 56 | +::: {.callout-note collapse="true"} |
| 57 | +## How to randomly initialize? |
| 58 | + |
| 59 | +You can use `np.random.uniform` to generate random angles for theta and random positions for xy. Make sure to set the shape correctly for the number of boids and dimensions. |
| 60 | +::: |
| 61 | + |
| 62 | + |
| 63 | +::: {.callout-tip collapse="true"} |
| 64 | +## What happens if you run it for $N=1000$? |
| 65 | + |
| 66 | +Expected error should decrease towards zero as the number of boids increases, since the average distance to the nearest neighbor should decrease. |
| 67 | +::: |
| 68 | + |
| 69 | + |
| 70 | +## Example Figure |
| 71 | + |
| 72 | +Figures are generated in code chunks and can be referenced in the text: |
| 73 | + |
| 74 | +```{python} |
| 75 | +#| label: fig-random |
| 76 | +#| fig-cap: 'Random walk of particles' |
| 77 | +#| fig-width: 6 |
| 78 | +#| fig-height: 6 |
| 79 | +#| echo: false |
| 80 | +
|
| 81 | +import matplotlib.pyplot as plt |
| 82 | +import numpy as np |
| 83 | +
|
| 84 | +xy = np.random.rand(2, 1000) * 10 |
| 85 | +
|
| 86 | +plt.scatter(xy[0], xy[1], s=10) |
| 87 | +plt.title('Random Walk of Particles') |
| 88 | +plt.xlabel('x') |
| 89 | +plt.ylabel('y') |
| 90 | +plt.show() |
| 91 | +``` |
0 commit comments