You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+70-73Lines changed: 70 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,72 +2,42 @@
2
2
3
3
## Overview
4
4
5
-
**PyTensor**: Python library for defining, optimizing, and evaluating mathematical expressions with multi-dimensional arrays. Computational backend for PyMC with extensible graph framework. Supports C, JAX, and Numba compilation backends. ~27MB, 492 Python files, Python 3.11-3.13, uses NumPy, SciPy, pytest, Sphinx.
6
-
7
-
## Critical: Environment & Commands
8
-
9
-
**ALWAYS use micromamba environment**: PyTensor is pre-installed in `.github/workflows/copilot-setup-steps.yml`.
10
-
11
-
All commands MUST use: `micromamba run -n pytensor-test <command>`
12
-
13
-
Example: `micromamba run -n pytensor-test python -m pytest tests/`
14
-
15
-
## Testing & Building
16
-
17
-
### Running Tests (ALWAYS use micromamba)
18
-
19
-
```bash
20
-
micromamba run -n pytensor-test python -m pytest tests/ # All tests (10-20 min)
21
-
micromamba run -n pytensor-test python -m pytest tests/test_updates.py -v # Single file (<2 min)
22
-
micromamba run -n pytensor-test python -m pytest tests/ --runslow # Include slow tests
23
-
```
24
-
25
-
### Code Style
26
-
27
-
**DO NOT run pre-commit/ruff locally** - they're not in copilot environment. CI handles style validation via `.github/workflows/test.yml`.
28
-
29
-
### Documentation
30
-
31
-
```bash
32
-
micromamba run -n pytensor-test python -m sphinx -b html ./doc ./html # Build docs (2-3 min)
33
-
```
34
-
**Never commit `html` directory**.
35
-
36
-
### MyPy
37
-
38
-
```bash
39
-
micromamba run -n pytensor-test python ./scripts/run_mypy.py --verbose
40
-
```
41
-
**PyTensor incompatible with strict mypy**. Liberal `type: ignore[rule]` and file exclusions are acceptable.
5
+
**PyTensor**: Python library for defining, optimizing, and evaluating mathematical expressions with multi-dimensional arrays. Focus on hackable graph analysis and manipulation. Supports C, JAX, and Numba compilation backends. ~27MB, 492 Python files, Python support as per numpy NEP 29, uses NumPy, SciPy, pytest.
42
6
43
7
## PyTensor Design Principles
44
8
9
+
Graph manipulation in Python, graph evaluation out of Python.
10
+
Emulate NumPy user-facing API as much as possible.
11
+
45
12
### API Differences from NumPy
46
13
47
14
1.**Lazy evaluation**: Expressions are symbolic until `pytensor.function()` compiles or `.eval()` evaluates
48
-
2.**Pure semantics**: Use `new_x = x[idx].set(y)` instead of `x[idx] = y`
49
-
3.**Immutable/hashable**: `a == b` tests identity (`a is b`), not equality
15
+
2.**Pure semantics**: `new_x = x[idx].set(y)` instead of `x[idx] = y`
16
+
3.**Immutable/hashable**: PyTensor variables are hashable. `a == b` tests identity (`a is b`), not elemntwise equality.
50
17
4.**Static shapes**: Broadcasting requires static shape of 1. Valid: `pt.add(pt.vector("x", shape=(1,)), pt.vector("y"))`. Invalid: `pt.add(pt.vector("x", shape=(None,)), pt.vector("y"))` with x.shape=1.
18
+
5.**Static rank and type**. PyTensor functions accepts variables with a specfic dtype and number of dimensions. Length of each dimension can be static or dynamic.
51
19
52
-
### Config Flags
20
+
##Code Style
53
21
54
-
Tests run with `config.floatX == "float32"` and `config.mode = "FAST_COMPILE"`:
- Skip FAST_COMPILE if test depends on optimizations
87
+
### MyPy
116
88
117
-
## Trust These Instructions
89
+
```bash
90
+
micromamba run -n pytensor-test python ./scripts/run_mypy.py --verbose
91
+
```
92
+
**PyTensor incompatible with strict mypy**. Type-hints are for users/developers not to appease mypy. Liberal `type: ignore[rule]` and file exclusions are acceptable.
118
93
119
-
Comprehensive and tested. Search only if: (1) incomplete, (2) incorrect, or (3) need deeper implementation details.
94
+
### Documentation
95
+
96
+
```bash
97
+
micromamba run -n pytensor-test python -m sphinx -b html ./doc ./html # Build docs (2-3 min)
98
+
```
99
+
**Never commit `html` directory**.
100
+
101
+
102
+
## CI/CD Pipeline
103
+
104
+
### Workflows (`.github/workflows/`)
105
+
1.**test.yml**: Main suite - Several Python versions, fast-compile (0/1), float32 (0/1), 7 test parts + backend jobs (numba, jax, torch)
106
+
2.**mypy.yml**: Type checking
107
+
3.**copilot-setup-steps.yml**: Environment setup
108
+
109
+
110
+
## Trust These Instructions
111
+
These instructions are comprehensive and tested. Only search for additional information if:
112
+
1. Instructions are incomplete for your specific task
113
+
2. Instructions are found to be incorrect
114
+
3. You need deeper understanding of an implementation detail
115
+
116
+
For most coding tasks, these instructions provide everything needed to build, test, and validate changes efficiently.
0 commit comments