-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (70 loc) · 2.13 KB
/
Copy pathci.yml
File metadata and controls
76 lines (70 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: CI
on:
pull_request:
push:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: uv sync --locked
- run: uv run ruff check tbm tests examples
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: uv sync --locked
- run: uv run pytest
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: uv build
- run: python -m venv /tmp/tbm-wheel-test
- run: /tmp/tbm-wheel-test/bin/python -m pip install --upgrade pip
- run: /tmp/tbm-wheel-test/bin/python -m pip install dist/*.whl
- name: Smoke test installed wheel
working-directory: /tmp
run: |
/tmp/tbm-wheel-test/bin/python - <<'PY'
import numpy as np
from tbm import InitialGuess, TBMConfig, TBMProblem, solve
def rollout(initial_states, control_segments):
states = np.zeros((initial_states.shape[0], control_segments.shape[1] + 1, 1))
states[:, 0, :] = initial_states
for step in range(control_segments.shape[1]):
states[:, step + 1, 0] = states[:, step, 0] + control_segments[:, step, 0]
return states
result = solve(
TBMProblem(
state_dim=1,
control_dim=1,
horizon=2,
initial_state=np.array([0.0]),
rollout=rollout,
),
InitialGuess(controls=np.zeros((1, 1))),
TBMConfig(max_iterations=1),
)
assert result.history
PY