Freeze SmoothLife model contract and fixtures
This commit is contained in:
310
tests/fixtures/contract/curves.json
vendored
Normal file
310
tests/fixtures/contract/curves.json
vendored
Normal file
@@ -0,0 +1,310 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"description": "Boundary samples for every scalar curve and explicit overshoot samples.",
|
||||
"rising": {
|
||||
"center": 0.5,
|
||||
"width": 0.2,
|
||||
"x": [
|
||||
0.3,
|
||||
0.39999999999900004,
|
||||
0.4,
|
||||
0.5,
|
||||
0.6,
|
||||
0.600000000001,
|
||||
0.7
|
||||
],
|
||||
"curves": [
|
||||
{
|
||||
"type": 0,
|
||||
"values": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"values": [
|
||||
0.0,
|
||||
0.0,
|
||||
1.3877787807814457e-16,
|
||||
0.5,
|
||||
0.9999999999999999,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 2,
|
||||
"values": [
|
||||
0.0,
|
||||
0.0,
|
||||
5.777789833161706e-32,
|
||||
0.5,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 3,
|
||||
"values": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.5,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 4,
|
||||
"values": [
|
||||
0.017986209962091555,
|
||||
0.1192029220200178,
|
||||
0.1192029220221176,
|
||||
0.5,
|
||||
0.8807970779778823,
|
||||
0.8807970779799822,
|
||||
0.9820137900379085
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 5,
|
||||
"values": [
|
||||
0.09809326195229362,
|
||||
0.18045353661261226,
|
||||
0.18045353661405417,
|
||||
0.5,
|
||||
0.8195464633859458,
|
||||
0.8195464633873877,
|
||||
0.9019067380477064
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 6,
|
||||
"values": [
|
||||
0.23570975446453796,
|
||||
0.3392463751246173,
|
||||
0.3392463751259724,
|
||||
0.5,
|
||||
0.6607536248740276,
|
||||
0.6607536248753827,
|
||||
0.7642902455354621
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 7,
|
||||
"values": [
|
||||
-0.15933675375398315,
|
||||
-0.1773621405006125,
|
||||
-0.17736214049836008,
|
||||
0.5,
|
||||
1.17736214049836,
|
||||
1.1773621405006125,
|
||||
1.1593367537539834
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"windows": {
|
||||
"a": 0.3,
|
||||
"b": 0.7,
|
||||
"width": 0.1,
|
||||
"x": [
|
||||
0.249999999999,
|
||||
0.25,
|
||||
0.3,
|
||||
0.5,
|
||||
0.7,
|
||||
0.75,
|
||||
0.750000000001
|
||||
],
|
||||
"curves": [
|
||||
{
|
||||
"type": 0,
|
||||
"values": [
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"values": [
|
||||
0.0,
|
||||
1.3877787807814457e-16,
|
||||
0.5,
|
||||
1.0,
|
||||
0.5,
|
||||
-4.440892098500626e-16,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 2,
|
||||
"values": [
|
||||
0.0,
|
||||
5.777789833161706e-32,
|
||||
0.5,
|
||||
1.0,
|
||||
0.5,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 3,
|
||||
"values": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.5,
|
||||
1.0,
|
||||
0.5,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 4,
|
||||
"values": [
|
||||
0.11920292020245979,
|
||||
0.11920292020665954,
|
||||
0.49999994373241896,
|
||||
0.9993294121987771,
|
||||
0.49999994373241896,
|
||||
0.11920292020665929,
|
||||
0.11920292020245965
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 5,
|
||||
"values": [
|
||||
0.17639723377201547,
|
||||
0.17639723377482563,
|
||||
0.48736148525244144,
|
||||
0.9020455236180753,
|
||||
0.48736148525244144,
|
||||
0.17639723377482552,
|
||||
0.1763972337720154
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 6,
|
||||
"values": [
|
||||
0.29835047783952967,
|
||||
0.2983504778420687,
|
||||
0.4466576363081552,
|
||||
0.7613624350113533,
|
||||
0.4466576363081552,
|
||||
0.29835047784206853,
|
||||
0.29835047783952956
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 7,
|
||||
"values": [
|
||||
-0.1773621379439966,
|
||||
-0.17736213793949165,
|
||||
0.4999999718662063,
|
||||
1.0177103819486473,
|
||||
0.4999999718662063,
|
||||
-0.17736213793949188,
|
||||
-0.17736213794399672
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 8,
|
||||
"values": [
|
||||
0.11920292020212869,
|
||||
0.11920292020632844,
|
||||
0.4999999324789028,
|
||||
0.7994635297590218,
|
||||
0.4999999324789028,
|
||||
0.1192029202063282,
|
||||
0.11920292020212855
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 9,
|
||||
"values": [
|
||||
0.11920292020279089,
|
||||
0.11920292020699064,
|
||||
0.49999995498593514,
|
||||
1.1991952946385325,
|
||||
0.49999995498593514,
|
||||
0.11920292020699039,
|
||||
0.11920292020279075
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"overshoot": [
|
||||
{
|
||||
"type": 6,
|
||||
"samples": [
|
||||
{
|
||||
"x": 0.096,
|
||||
"value": 0.1715399896768695
|
||||
},
|
||||
{
|
||||
"x": 0.364,
|
||||
"value": 0.29468269649147805
|
||||
},
|
||||
{
|
||||
"x": 0.5,
|
||||
"value": 0.5
|
||||
},
|
||||
{
|
||||
"x": 0.636,
|
||||
"value": 0.705317303508522
|
||||
},
|
||||
{
|
||||
"x": 0.904,
|
||||
"value": 0.8284600103231305
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": 7,
|
||||
"samples": [
|
||||
{
|
||||
"x": 0.096,
|
||||
"value": -0.008135544802172934
|
||||
},
|
||||
{
|
||||
"x": 0.364,
|
||||
"value": -0.21415973191618876
|
||||
},
|
||||
{
|
||||
"x": 0.5,
|
||||
"value": 0.5
|
||||
},
|
||||
{
|
||||
"x": 0.636,
|
||||
"value": 1.2141597319161888
|
||||
},
|
||||
{
|
||||
"x": 0.904,
|
||||
"value": 1.008135544802173
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"hard_window_exact_interval": {
|
||||
"a": 0.3,
|
||||
"b": 0.7,
|
||||
"at_a": 1.0,
|
||||
"below_b": 1.0,
|
||||
"at_b": 0.0
|
||||
}
|
||||
}
|
||||
1121
tests/fixtures/contract/delayed_time.json
vendored
Normal file
1121
tests/fixtures/contract/delayed_time.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
657
tests/fixtures/contract/indexing.json
vendored
Normal file
657
tests/fixtures/contract/indexing.json
vendored
Normal file
@@ -0,0 +1,657 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"description": "Canonical x-fast indexing, inverse indexing, wrapping, and signed even offsets.",
|
||||
"shapes": [
|
||||
{
|
||||
"shape": [
|
||||
8
|
||||
],
|
||||
"x_fast_formula": "x + Nx*(y + Ny*z) (truncated to rank)",
|
||||
"entries": [
|
||||
{
|
||||
"coords": [
|
||||
0
|
||||
],
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1
|
||||
],
|
||||
"index": 1
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2
|
||||
],
|
||||
"index": 2
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3
|
||||
],
|
||||
"index": 3
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
4
|
||||
],
|
||||
"index": 4
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
5
|
||||
],
|
||||
"index": 5
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
6
|
||||
],
|
||||
"index": 6
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
7
|
||||
],
|
||||
"index": 7
|
||||
}
|
||||
],
|
||||
"inverse": [
|
||||
[
|
||||
0
|
||||
],
|
||||
[
|
||||
1
|
||||
],
|
||||
[
|
||||
2
|
||||
],
|
||||
[
|
||||
3
|
||||
],
|
||||
[
|
||||
4
|
||||
],
|
||||
[
|
||||
5
|
||||
],
|
||||
[
|
||||
6
|
||||
],
|
||||
[
|
||||
7
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"shape": [
|
||||
5,
|
||||
3
|
||||
],
|
||||
"x_fast_formula": "x + Nx*(y + Ny*z) (truncated to rank)",
|
||||
"entries": [
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
0
|
||||
],
|
||||
"index": 1
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
0
|
||||
],
|
||||
"index": 2
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
0
|
||||
],
|
||||
"index": 3
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
4,
|
||||
0
|
||||
],
|
||||
"index": 4
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
1
|
||||
],
|
||||
"index": 5
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
1
|
||||
],
|
||||
"index": 6
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
1
|
||||
],
|
||||
"index": 7
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
1
|
||||
],
|
||||
"index": 8
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
4,
|
||||
1
|
||||
],
|
||||
"index": 9
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
2
|
||||
],
|
||||
"index": 10
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"index": 11
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
2
|
||||
],
|
||||
"index": 12
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
2
|
||||
],
|
||||
"index": 13
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
4,
|
||||
2
|
||||
],
|
||||
"index": 14
|
||||
}
|
||||
],
|
||||
"inverse": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
1,
|
||||
0
|
||||
],
|
||||
[
|
||||
2,
|
||||
0
|
||||
],
|
||||
[
|
||||
3,
|
||||
0
|
||||
],
|
||||
[
|
||||
4,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
2,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
4,
|
||||
1
|
||||
],
|
||||
[
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
3,
|
||||
2
|
||||
],
|
||||
[
|
||||
4,
|
||||
2
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"shape": [
|
||||
4,
|
||||
3,
|
||||
2
|
||||
],
|
||||
"x_fast_formula": "x + Nx*(y + Ny*z) (truncated to rank)",
|
||||
"entries": [
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"index": 1
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"index": 2
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"index": 3
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"index": 4
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"index": 5
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"index": 6
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"index": 7
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
2,
|
||||
0
|
||||
],
|
||||
"index": 8
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
2,
|
||||
0
|
||||
],
|
||||
"index": 9
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
2,
|
||||
0
|
||||
],
|
||||
"index": 10
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
2,
|
||||
0
|
||||
],
|
||||
"index": 11
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"index": 12
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"index": 13
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"index": 14
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"index": 15
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"index": 16
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"index": 17
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"index": 18
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"index": 19
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
2,
|
||||
1
|
||||
],
|
||||
"index": 20
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
2,
|
||||
1
|
||||
],
|
||||
"index": 21
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
2,
|
||||
2,
|
||||
1
|
||||
],
|
||||
"index": 22
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
2,
|
||||
1
|
||||
],
|
||||
"index": 23
|
||||
}
|
||||
],
|
||||
"inverse": [
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
2,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
3,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
0
|
||||
],
|
||||
[
|
||||
1,
|
||||
1,
|
||||
0
|
||||
],
|
||||
[
|
||||
2,
|
||||
1,
|
||||
0
|
||||
],
|
||||
[
|
||||
3,
|
||||
1,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0
|
||||
],
|
||||
[
|
||||
1,
|
||||
2,
|
||||
0
|
||||
],
|
||||
[
|
||||
2,
|
||||
2,
|
||||
0
|
||||
],
|
||||
[
|
||||
3,
|
||||
2,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
1
|
||||
],
|
||||
[
|
||||
2,
|
||||
0,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
0,
|
||||
1
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
2,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
2,
|
||||
1
|
||||
],
|
||||
[
|
||||
2,
|
||||
2,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
2,
|
||||
1
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
"signed_offsets": [
|
||||
{
|
||||
"extent": 2,
|
||||
"values": [
|
||||
0,
|
||||
-1
|
||||
]
|
||||
},
|
||||
{
|
||||
"extent": 4,
|
||||
"values": [
|
||||
0,
|
||||
1,
|
||||
-2,
|
||||
-1
|
||||
]
|
||||
},
|
||||
{
|
||||
"extent": 6,
|
||||
"values": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
-3,
|
||||
-2,
|
||||
-1
|
||||
]
|
||||
},
|
||||
{
|
||||
"extent": 8,
|
||||
"values": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
-4,
|
||||
-3,
|
||||
-2,
|
||||
-1
|
||||
]
|
||||
}
|
||||
],
|
||||
"wrap_examples": [
|
||||
{
|
||||
"value": -9,
|
||||
"extent": 8,
|
||||
"wrapped": 7
|
||||
},
|
||||
{
|
||||
"value": -1,
|
||||
"extent": 8,
|
||||
"wrapped": 7
|
||||
},
|
||||
{
|
||||
"value": 8,
|
||||
"extent": 8,
|
||||
"wrapped": 0
|
||||
},
|
||||
{
|
||||
"value": 17,
|
||||
"extent": 8,
|
||||
"wrapped": 1
|
||||
},
|
||||
{
|
||||
"value": -7,
|
||||
"extent": 6,
|
||||
"wrapped": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
5409
tests/fixtures/contract/initializers.json
vendored
Normal file
5409
tests/fixtures/contract/initializers.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
345
tests/fixtures/contract/integration.json
vendored
Normal file
345
tests/fixtures/contract/integration.json
vendored
Normal file
@@ -0,0 +1,345 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"description": "Clamp-at-commit Euler/AB and clamp-every-stage RK4, including both relaxation references.",
|
||||
"initial": [
|
||||
0.02,
|
||||
0.37,
|
||||
0.81,
|
||||
0.98
|
||||
],
|
||||
"time": 0.25,
|
||||
"dt": 0.4,
|
||||
"synthetic_derivative": "k_i(A,t)=0.34-0.45*A_i+(i+1)*0.08*t",
|
||||
"euler": {
|
||||
"k1": [
|
||||
0.35100000000000003,
|
||||
0.21350000000000002,
|
||||
0.035499999999999976,
|
||||
-0.020999999999999977
|
||||
],
|
||||
"next": [
|
||||
0.16040000000000001,
|
||||
0.4554,
|
||||
0.8242,
|
||||
0.9716
|
||||
]
|
||||
},
|
||||
"ab3_startup": {
|
||||
"methods": [
|
||||
"Euler",
|
||||
"AB2",
|
||||
"AB3"
|
||||
],
|
||||
"states": [
|
||||
[
|
||||
0.02,
|
||||
0.37,
|
||||
0.81,
|
||||
0.98
|
||||
],
|
||||
[
|
||||
0.16040000000000001,
|
||||
0.4554,
|
||||
0.8242,
|
||||
0.9716
|
||||
],
|
||||
[
|
||||
0.282092,
|
||||
0.556142,
|
||||
0.892166,
|
||||
1.0
|
||||
],
|
||||
[
|
||||
0.39776626000000004,
|
||||
0.6618190100000001,
|
||||
0.97742673,
|
||||
1.0
|
||||
]
|
||||
],
|
||||
"derivatives": [
|
||||
[
|
||||
0.35100000000000003,
|
||||
0.21350000000000002,
|
||||
0.035499999999999976,
|
||||
-0.020999999999999977
|
||||
],
|
||||
[
|
||||
0.31982,
|
||||
0.23907,
|
||||
0.12510999999999997,
|
||||
0.11078000000000005
|
||||
],
|
||||
[
|
||||
0.2970586,
|
||||
0.2577361,
|
||||
0.1905253,
|
||||
0.22600000000000003
|
||||
]
|
||||
],
|
||||
"ab2_combination": [
|
||||
0.30423,
|
||||
0.251855,
|
||||
0.16991499999999998,
|
||||
0.17667000000000005
|
||||
],
|
||||
"ab3_combination": [
|
||||
0.28918565,
|
||||
0.26419252500000007,
|
||||
0.21315182500000004,
|
||||
0.27670999999999996
|
||||
]
|
||||
},
|
||||
"rk4": {
|
||||
"stage_states": [
|
||||
[
|
||||
0.02,
|
||||
0.37,
|
||||
0.81,
|
||||
0.98
|
||||
],
|
||||
[
|
||||
0.09020000000000002,
|
||||
0.4127,
|
||||
0.8171,
|
||||
0.9758
|
||||
],
|
||||
[
|
||||
0.087082,
|
||||
0.415257,
|
||||
0.826061,
|
||||
0.988978
|
||||
],
|
||||
[
|
||||
0.15472523999999999,
|
||||
0.46005374,
|
||||
0.84050902,
|
||||
0.99558396
|
||||
]
|
||||
],
|
||||
"derivatives": [
|
||||
[
|
||||
0.35100000000000003,
|
||||
0.21350000000000002,
|
||||
0.035499999999999976,
|
||||
-0.020999999999999977
|
||||
],
|
||||
[
|
||||
0.33541,
|
||||
0.22628500000000001,
|
||||
0.08030499999999997,
|
||||
0.04489000000000004
|
||||
],
|
||||
[
|
||||
0.3368131,
|
||||
0.22513435000000004,
|
||||
0.07627255000000001,
|
||||
0.03895990000000005
|
||||
],
|
||||
[
|
||||
0.322373642,
|
||||
0.23697581700000003,
|
||||
0.11777094099999999,
|
||||
0.09998721799999999
|
||||
]
|
||||
],
|
||||
"combined": [
|
||||
0.33630330699999994,
|
||||
0.22555241950000002,
|
||||
0.07773767349999999,
|
||||
0.04111450300000003
|
||||
],
|
||||
"next": [
|
||||
0.15452132279999997,
|
||||
0.4602209678,
|
||||
0.8410950694,
|
||||
0.9964458012
|
||||
]
|
||||
},
|
||||
"relaxation_target": "S_i(A)=0.1+0.65*A_(i-1)+0.2*A_(i+1), periodic",
|
||||
"rk4_relaxation_stage_state": {
|
||||
"reference": "stage_state",
|
||||
"stage_states": [
|
||||
[
|
||||
0.02,
|
||||
0.37,
|
||||
0.81,
|
||||
0.98
|
||||
],
|
||||
[
|
||||
0.1782,
|
||||
0.351,
|
||||
0.7553000000000001,
|
||||
0.9101
|
||||
],
|
||||
[
|
||||
0.136713,
|
||||
0.373178,
|
||||
0.760974,
|
||||
0.923297
|
||||
],
|
||||
[
|
||||
0.27522626000000006,
|
||||
0.3571521,
|
||||
0.7165004400000001,
|
||||
0.85947148
|
||||
]
|
||||
],
|
||||
"targets": [
|
||||
[
|
||||
0.8109999999999999,
|
||||
0.275,
|
||||
0.5365,
|
||||
0.6305000000000001
|
||||
],
|
||||
[
|
||||
0.761765,
|
||||
0.36689000000000005,
|
||||
0.51017,
|
||||
0.6265850000000001
|
||||
],
|
||||
[
|
||||
0.77477865,
|
||||
0.34105825,
|
||||
0.5272251000000001,
|
||||
0.6219757
|
||||
],
|
||||
[
|
||||
0.7300868819999999,
|
||||
0.42219715700000005,
|
||||
0.504043161,
|
||||
0.620770538
|
||||
]
|
||||
],
|
||||
"derivatives": [
|
||||
[
|
||||
0.7909999999999999,
|
||||
-0.09499999999999997,
|
||||
-0.2735000000000001,
|
||||
-0.3494999999999999
|
||||
],
|
||||
[
|
||||
0.583565,
|
||||
0.01589000000000007,
|
||||
-0.24513000000000007,
|
||||
-0.28351499999999996
|
||||
],
|
||||
[
|
||||
0.63806565,
|
||||
-0.03211975,
|
||||
-0.23374889999999993,
|
||||
-0.3013213
|
||||
],
|
||||
[
|
||||
0.4548606219999999,
|
||||
0.06504505700000007,
|
||||
-0.2124572790000001,
|
||||
-0.23870094199999992
|
||||
]
|
||||
],
|
||||
"combined": [
|
||||
0.6148536536666667,
|
||||
-0.010402407166666627,
|
||||
-0.24061917983333336,
|
||||
-0.2929789236666666
|
||||
],
|
||||
"next": [
|
||||
0.2659414614666667,
|
||||
0.3658390371333333,
|
||||
0.7137523280666667,
|
||||
0.8628084305333333
|
||||
]
|
||||
},
|
||||
"rk4_relaxation_step_origin": {
|
||||
"reference": "step_origin",
|
||||
"stage_states": [
|
||||
[
|
||||
0.02,
|
||||
0.37,
|
||||
0.81,
|
||||
0.98
|
||||
],
|
||||
[
|
||||
0.1782,
|
||||
0.351,
|
||||
0.7553000000000001,
|
||||
0.9101
|
||||
],
|
||||
[
|
||||
0.168353,
|
||||
0.369378,
|
||||
0.7500340000000001,
|
||||
0.909317
|
||||
],
|
||||
[
|
||||
0.3179726600000001,
|
||||
0.3657745,
|
||||
0.69478364,
|
||||
0.83647708
|
||||
]
|
||||
],
|
||||
"targets": [
|
||||
[
|
||||
0.8109999999999999,
|
||||
0.275,
|
||||
0.5365,
|
||||
0.6305000000000001
|
||||
],
|
||||
[
|
||||
0.761765,
|
||||
0.36689000000000005,
|
||||
0.51017,
|
||||
0.6265850000000001
|
||||
],
|
||||
[
|
||||
0.7649316500000001,
|
||||
0.35943625,
|
||||
0.5219591,
|
||||
0.6211927
|
||||
],
|
||||
[
|
||||
0.716865002,
|
||||
0.4456389570000001,
|
||||
0.505048841,
|
||||
0.615203898
|
||||
]
|
||||
],
|
||||
"derivatives": [
|
||||
[
|
||||
0.7909999999999999,
|
||||
-0.09499999999999997,
|
||||
-0.2735000000000001,
|
||||
-0.3494999999999999
|
||||
],
|
||||
[
|
||||
0.741765,
|
||||
-0.003109999999999946,
|
||||
-0.29983000000000004,
|
||||
-0.3534149999999999
|
||||
],
|
||||
[
|
||||
0.7449316500000001,
|
||||
-0.010563749999999983,
|
||||
-0.28804090000000004,
|
||||
-0.35880729999999994
|
||||
],
|
||||
[
|
||||
0.696865002,
|
||||
0.07563895700000012,
|
||||
-0.304951159,
|
||||
-0.364796102
|
||||
]
|
||||
],
|
||||
"combined": [
|
||||
0.7435430503333333,
|
||||
-0.007784757166666619,
|
||||
-0.2923654931666667,
|
||||
-0.3564567836666666
|
||||
],
|
||||
"next": [
|
||||
0.31741722013333334,
|
||||
0.36688609713333337,
|
||||
0.6930538027333334,
|
||||
0.8374172865333334
|
||||
]
|
||||
}
|
||||
}
|
||||
4857
tests/fixtures/contract/legacy_packed_fft.json
vendored
Normal file
4857
tests/fixtures/contract/legacy_packed_fft.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
72
tests/fixtures/contract/manifest.json
vendored
Normal file
72
tests/fixtures/contract/manifest.json
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"contract": "Macrostep 00 deterministic oracle fixtures",
|
||||
"generator": "tools/generate_contract_fixtures.py",
|
||||
"oracle": "tools/contract_oracle.py",
|
||||
"standard_library_only": true,
|
||||
"semantic_float": "IEEE-754 binary64 represented as JSON numbers",
|
||||
"packed_fft_float": "IEEE-754 binary32 after every operation, with decimal values and hexadecimal bit patterns",
|
||||
"determinism": "No timestamp, locale, platform RNG, external source tree, or runtime dependency is used.",
|
||||
"files": [
|
||||
{
|
||||
"path": "indexing.json",
|
||||
"description": "Indexing and signed offsets",
|
||||
"bytes": 9147,
|
||||
"sha256": "c6b8948d6048bb3a8e7199a0736ea9f0f0bef2b0d0852593544a51e2aea51cdb"
|
||||
},
|
||||
{
|
||||
"path": "curves.json",
|
||||
"description": "Scalar curves and boundaries",
|
||||
"bytes": 5751,
|
||||
"sha256": "a70fef48668b1205fe420d3ea9de55860355ebcb34ef24ace70a838f707498cc"
|
||||
},
|
||||
{
|
||||
"path": "rule_surface.json",
|
||||
"description": "Complete rule enum surface",
|
||||
"bytes": 109184,
|
||||
"sha256": "169fb64eb333c49b41e425ecbeea4a47ae9e0be8d5c3271363306927838091c0"
|
||||
},
|
||||
{
|
||||
"path": "planar_fields.json",
|
||||
"description": "Sampled kernels and direct convolution",
|
||||
"bytes": 20013,
|
||||
"sha256": "b3c6b226e64c079fd3a507abac993745572b670d9babf3673afd7bc7b3955881"
|
||||
},
|
||||
{
|
||||
"path": "legacy_packed_fft.json",
|
||||
"description": "Packed-unitary f32 FFT oracle",
|
||||
"bytes": 113770,
|
||||
"sha256": "28e23e349faa9f330800be1a73dd0ef5e83a637b6dbab256c6a6adb51d33452b"
|
||||
},
|
||||
{
|
||||
"path": "integration.json",
|
||||
"description": "Euler, AB startup, RK4 references",
|
||||
"bytes": 6229,
|
||||
"sha256": "0bd9f394e3828254c25cf5958b58ad68d6fd0f6e5cda460e8ef8f89d4cf3cee0"
|
||||
},
|
||||
{
|
||||
"path": "multiscale.json",
|
||||
"description": "All multiscale policies",
|
||||
"bytes": 69725,
|
||||
"sha256": "31a79957d2f0b3aebd5f33610a5c95bbd75dc1efe514d67eab929348dec94d22"
|
||||
},
|
||||
{
|
||||
"path": "sphere.json",
|
||||
"description": "Corrected and legacy sphere",
|
||||
"bytes": 126178,
|
||||
"sha256": "b95d649556bc86636ed75ac28c6688afd3a998bbc403897c840115d81be87faa"
|
||||
},
|
||||
{
|
||||
"path": "delayed_time.json",
|
||||
"description": "Causal delayed-time shells",
|
||||
"bytes": 21449,
|
||||
"sha256": "02088cbb78a8e58326235d80d75e0fb89d056501696c4c647b8b977ecb582a81"
|
||||
},
|
||||
{
|
||||
"path": "initializers.json",
|
||||
"description": "ChaCha12 and exact seeded arrays",
|
||||
"bytes": 71752,
|
||||
"sha256": "7a549a1270a89c7cb5bc3fdaae5c6cb5b3bf51ffc0583f1ec1d9994658ace576"
|
||||
}
|
||||
]
|
||||
}
|
||||
2696
tests/fixtures/contract/multiscale.json
vendored
Normal file
2696
tests/fixtures/contract/multiscale.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
971
tests/fixtures/contract/planar_fields.json
vendored
Normal file
971
tests/fixtures/contract/planar_fields.json
vendored
Normal file
@@ -0,0 +1,971 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"description": "Asymmetric f64 fields with complete sampled kernels and direct circular convolutions.",
|
||||
"convolution_sign": "out[x] = sum_offset field[x-offset] * kernel[offset] with every axis periodic",
|
||||
"cases": [
|
||||
{
|
||||
"rank": 1,
|
||||
"shape": [
|
||||
8
|
||||
],
|
||||
"field": [
|
||||
0.0,
|
||||
0.17,
|
||||
0.91,
|
||||
0.26,
|
||||
0.73,
|
||||
0.42,
|
||||
0.08,
|
||||
0.64
|
||||
],
|
||||
"kernel": {
|
||||
"shape": [
|
||||
8
|
||||
],
|
||||
"ra": 1.45,
|
||||
"rr": 3.0,
|
||||
"rb": 5.0,
|
||||
"ri": 0.48333333333333334,
|
||||
"width": 0.29,
|
||||
"raw_disk": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"raw_ring": [
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
],
|
||||
"disk_sum": 1.0,
|
||||
"ring_sum": 2.0,
|
||||
"normalized_disk": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"normalized_ring": [
|
||||
0.0,
|
||||
0.5,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.5
|
||||
],
|
||||
"support": [
|
||||
{
|
||||
"coords": [
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
0
|
||||
],
|
||||
"radius": 0.0,
|
||||
"disk": 1.0,
|
||||
"ring": 0.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
1
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
7
|
||||
],
|
||||
"offset": [
|
||||
-1
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
}
|
||||
],
|
||||
"warnings": []
|
||||
},
|
||||
"direct_disk_convolution_raw": [
|
||||
0.0,
|
||||
0.17,
|
||||
0.91,
|
||||
0.26,
|
||||
0.73,
|
||||
0.42,
|
||||
0.08,
|
||||
0.64
|
||||
],
|
||||
"direct_ring_convolution_raw": [
|
||||
0.81,
|
||||
0.91,
|
||||
0.43000000000000005,
|
||||
1.6400000000000001,
|
||||
0.6799999999999999,
|
||||
0.8099999999999999,
|
||||
1.06,
|
||||
0.08
|
||||
],
|
||||
"M_disk_normalized": [
|
||||
0.0,
|
||||
0.17,
|
||||
0.91,
|
||||
0.26,
|
||||
0.73,
|
||||
0.42,
|
||||
0.08,
|
||||
0.64
|
||||
],
|
||||
"N_ring_normalized": [
|
||||
0.405,
|
||||
0.455,
|
||||
0.21500000000000002,
|
||||
0.8200000000000001,
|
||||
0.33999999999999997,
|
||||
0.40499999999999997,
|
||||
0.53,
|
||||
0.04
|
||||
]
|
||||
},
|
||||
{
|
||||
"rank": 2,
|
||||
"shape": [
|
||||
5,
|
||||
4
|
||||
],
|
||||
"field": [
|
||||
0.10714285714285714,
|
||||
0.5,
|
||||
0.8928571428571429,
|
||||
0.25,
|
||||
0.6428571428571429,
|
||||
0.0,
|
||||
0.39285714285714285,
|
||||
0.7857142857142857,
|
||||
0.14285714285714285,
|
||||
0.5357142857142857,
|
||||
0.9285714285714286,
|
||||
0.2857142857142857,
|
||||
0.6785714285714286,
|
||||
0.03571428571428571,
|
||||
0.42857142857142855,
|
||||
0.8214285714285714,
|
||||
0.17857142857142858,
|
||||
0.5714285714285714,
|
||||
0.9642857142857143,
|
||||
0.32142857142857145
|
||||
],
|
||||
"kernel": {
|
||||
"shape": [
|
||||
5,
|
||||
4
|
||||
],
|
||||
"ra": 1.45,
|
||||
"rr": 3.0,
|
||||
"rb": 5.0,
|
||||
"ri": 0.48333333333333334,
|
||||
"width": 0.29,
|
||||
"raw_disk": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"raw_ring": [
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0,
|
||||
0.6234015090582925,
|
||||
0.0,
|
||||
0.0,
|
||||
0.6234015090582925,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.6234015090582925,
|
||||
0.0,
|
||||
0.0,
|
||||
0.6234015090582925
|
||||
],
|
||||
"disk_sum": 1.0,
|
||||
"ring_sum": 6.49360603623317,
|
||||
"normalized_disk": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"normalized_ring": [
|
||||
0.0,
|
||||
0.15399763928088298,
|
||||
0.0,
|
||||
0.0,
|
||||
0.15399763928088298,
|
||||
0.15399763928088298,
|
||||
0.09600236071911702,
|
||||
0.0,
|
||||
0.0,
|
||||
0.09600236071911702,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.15399763928088298,
|
||||
0.09600236071911702,
|
||||
0.0,
|
||||
0.0,
|
||||
0.09600236071911702
|
||||
],
|
||||
"support": [
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"radius": 0.0,
|
||||
"disk": 1.0,
|
||||
"ring": 0.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
1,
|
||||
0
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
4,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
-1,
|
||||
0
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
1
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
1,
|
||||
1
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
4,
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
-1,
|
||||
1
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
3
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
3
|
||||
],
|
||||
"offset": [
|
||||
1,
|
||||
-1
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
4,
|
||||
3
|
||||
],
|
||||
"offset": [
|
||||
-1,
|
||||
-1
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
}
|
||||
],
|
||||
"warnings": []
|
||||
},
|
||||
"direct_disk_convolution_raw": [
|
||||
0.10714285714285714,
|
||||
0.5,
|
||||
0.8928571428571429,
|
||||
0.25,
|
||||
0.6428571428571429,
|
||||
0.0,
|
||||
0.39285714285714285,
|
||||
0.7857142857142857,
|
||||
0.14285714285714285,
|
||||
0.5357142857142857,
|
||||
0.9285714285714286,
|
||||
0.2857142857142857,
|
||||
0.6785714285714286,
|
||||
0.03571428571428571,
|
||||
0.42857142857142855,
|
||||
0.8214285714285714,
|
||||
0.17857142857142858,
|
||||
0.5714285714285714,
|
||||
0.9642857142857143,
|
||||
0.32142857142857145
|
||||
],
|
||||
"direct_ring_convolution_raw": [
|
||||
2.854859298654704,
|
||||
2.92955328759128,
|
||||
3.153566818776419,
|
||||
4.023246198629076,
|
||||
2.41656005318385,
|
||||
3.1220313739654,
|
||||
3.1967253629019767,
|
||||
2.775073045419599,
|
||||
3.2547039882254873,
|
||||
2.0380662798270297,
|
||||
2.4262878700832746,
|
||||
3.536696144734137,
|
||||
2.7249953902049913,
|
||||
3.594674770057648,
|
||||
3.023702910326707,
|
||||
2.693459945393972,
|
||||
3.8038682200448344,
|
||||
3.382215902562456,
|
||||
2.8261325596540585,
|
||||
3.6809234226841716
|
||||
],
|
||||
"M_disk_normalized": [
|
||||
0.10714285714285714,
|
||||
0.5,
|
||||
0.8928571428571429,
|
||||
0.25,
|
||||
0.6428571428571429,
|
||||
0.0,
|
||||
0.39285714285714285,
|
||||
0.7857142857142857,
|
||||
0.14285714285714285,
|
||||
0.5357142857142857,
|
||||
0.9285714285714286,
|
||||
0.2857142857142857,
|
||||
0.6785714285714286,
|
||||
0.03571428571428571,
|
||||
0.42857142857142855,
|
||||
0.8214285714285714,
|
||||
0.17857142857142858,
|
||||
0.5714285714285714,
|
||||
0.9642857142857143,
|
||||
0.32142857142857145
|
||||
],
|
||||
"N_ring_normalized": [
|
||||
0.43964159247190165,
|
||||
0.45114429043660675,
|
||||
0.4856418454060926,
|
||||
0.6195704168346641,
|
||||
0.3721445433707979,
|
||||
0.48078546135152317,
|
||||
0.4922881593162283,
|
||||
0.42735469782662877,
|
||||
0.5012167307447998,
|
||||
0.31385739579133404,
|
||||
0.37364260420866596,
|
||||
0.5446428571428571,
|
||||
0.4196428571428572,
|
||||
0.5535714285714286,
|
||||
0.4656431100770483,
|
||||
0.41478647308828764,
|
||||
0.5857867260224788,
|
||||
0.5208532645328791,
|
||||
0.4352177424815642,
|
||||
0.5668535174670701
|
||||
]
|
||||
},
|
||||
{
|
||||
"rank": 3,
|
||||
"shape": [
|
||||
4,
|
||||
3,
|
||||
2
|
||||
],
|
||||
"field": [
|
||||
0.1388888888888889,
|
||||
0.5,
|
||||
0.8611111111111112,
|
||||
0.19444444444444445,
|
||||
0.5555555555555556,
|
||||
0.9166666666666666,
|
||||
0.25,
|
||||
0.6111111111111112,
|
||||
0.9722222222222222,
|
||||
0.3055555555555556,
|
||||
0.6666666666666666,
|
||||
0.0,
|
||||
0.3611111111111111,
|
||||
0.7222222222222222,
|
||||
0.05555555555555555,
|
||||
0.4166666666666667,
|
||||
0.7777777777777778,
|
||||
0.1111111111111111,
|
||||
0.4722222222222222,
|
||||
0.8333333333333334,
|
||||
0.16666666666666666,
|
||||
0.5277777777777778,
|
||||
0.8888888888888888,
|
||||
0.2222222222222222
|
||||
],
|
||||
"kernel": {
|
||||
"shape": [
|
||||
4,
|
||||
3,
|
||||
2
|
||||
],
|
||||
"ra": 1.45,
|
||||
"rr": 3.0,
|
||||
"rb": 5.0,
|
||||
"ri": 0.48333333333333334,
|
||||
"width": 0.29,
|
||||
"raw_disk": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"raw_ring": [
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0,
|
||||
0.6234015090582925,
|
||||
0.0,
|
||||
0.6234015090582925,
|
||||
1.0,
|
||||
0.6234015090582925,
|
||||
0.0,
|
||||
0.6234015090582925,
|
||||
1.0,
|
||||
0.6234015090582925,
|
||||
0.0,
|
||||
0.6234015090582925,
|
||||
0.6234015090582925,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.6234015090582925,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"disk_sum": 1.0,
|
||||
"ring_sum": 9.98721207246634,
|
||||
"normalized_disk": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"normalized_ring": [
|
||||
0.0,
|
||||
0.10012804301581735,
|
||||
0.0,
|
||||
0.10012804301581735,
|
||||
0.10012804301581735,
|
||||
0.06241997311511416,
|
||||
0.0,
|
||||
0.06241997311511416,
|
||||
0.10012804301581735,
|
||||
0.06241997311511416,
|
||||
0.0,
|
||||
0.06241997311511416,
|
||||
0.10012804301581735,
|
||||
0.06241997311511416,
|
||||
0.0,
|
||||
0.06241997311511416,
|
||||
0.06241997311511416,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.06241997311511416,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"support": [
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"radius": 0.0,
|
||||
"disk": 1.0,
|
||||
"ring": 0.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
-1,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
1,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
-1,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
2,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
-1,
|
||||
0
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
2,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
1,
|
||||
-1,
|
||||
0
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
2,
|
||||
0
|
||||
],
|
||||
"offset": [
|
||||
-1,
|
||||
-1,
|
||||
0
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"radius": 1.0,
|
||||
"disk": 0.0,
|
||||
"ring": 1.0
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
1,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
1,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
3,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
-1,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
1,
|
||||
-1
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
},
|
||||
{
|
||||
"coords": [
|
||||
0,
|
||||
2,
|
||||
1
|
||||
],
|
||||
"offset": [
|
||||
0,
|
||||
-1,
|
||||
-1
|
||||
],
|
||||
"radius": 1.4142135623730951,
|
||||
"disk": 0.0,
|
||||
"ring": 0.6234015090582925
|
||||
}
|
||||
],
|
||||
"warnings": [
|
||||
"nonzero support touches periodic Nyquist offset on axis 2"
|
||||
]
|
||||
},
|
||||
"direct_disk_convolution_raw": [
|
||||
0.1388888888888889,
|
||||
0.5,
|
||||
0.8611111111111112,
|
||||
0.19444444444444445,
|
||||
0.5555555555555556,
|
||||
0.9166666666666666,
|
||||
0.25,
|
||||
0.6111111111111112,
|
||||
0.9722222222222222,
|
||||
0.3055555555555556,
|
||||
0.6666666666666666,
|
||||
0.0,
|
||||
0.3611111111111111,
|
||||
0.7222222222222222,
|
||||
0.05555555555555555,
|
||||
0.4166666666666667,
|
||||
0.7777777777777778,
|
||||
0.1111111111111111,
|
||||
0.4722222222222222,
|
||||
0.8333333333333334,
|
||||
0.16666666666666666,
|
||||
0.5277777777777778,
|
||||
0.8888888888888888,
|
||||
0.2222222222222222
|
||||
],
|
||||
"direct_ring_convolution_raw": [
|
||||
5.024989243811645,
|
||||
5.126349726148468,
|
||||
4.368073205919266,
|
||||
4.46943368825609,
|
||||
4.957853730727446,
|
||||
4.925813310438447,
|
||||
5.3287154706128455,
|
||||
4.655956832680603,
|
||||
3.729539537239647,
|
||||
5.886455575132025,
|
||||
4.4874608372595794,
|
||||
5.229539537239647,
|
||||
4.6638781327005345,
|
||||
4.378179054902825,
|
||||
5.4217994327204675,
|
||||
4.108322577144979,
|
||||
4.850401277125047,
|
||||
5.338821319596402,
|
||||
5.221263017010446,
|
||||
4.041187064060779,
|
||||
4.783265764040847,
|
||||
5.138284903886381,
|
||||
4.126349726148468,
|
||||
4.868428426128536
|
||||
],
|
||||
"M_disk_normalized": [
|
||||
0.1388888888888889,
|
||||
0.5,
|
||||
0.8611111111111112,
|
||||
0.19444444444444445,
|
||||
0.5555555555555556,
|
||||
0.9166666666666666,
|
||||
0.25,
|
||||
0.6111111111111112,
|
||||
0.9722222222222222,
|
||||
0.3055555555555556,
|
||||
0.6666666666666666,
|
||||
0.0,
|
||||
0.3611111111111111,
|
||||
0.7222222222222222,
|
||||
0.05555555555555555,
|
||||
0.4166666666666667,
|
||||
0.7777777777777778,
|
||||
0.1111111111111111,
|
||||
0.4722222222222222,
|
||||
0.8333333333333334,
|
||||
0.16666666666666666,
|
||||
0.5277777777777778,
|
||||
0.8888888888888888,
|
||||
0.2222222222222222
|
||||
],
|
||||
"N_ring_normalized": [
|
||||
0.5031423391583919,
|
||||
0.5132913658939172,
|
||||
0.4373666218585235,
|
||||
0.44751564859404896,
|
||||
0.4964201916164082,
|
||||
0.4932120470354665,
|
||||
0.5335538518605744,
|
||||
0.46619184602243213,
|
||||
0.3734314952139229,
|
||||
0.5893992770375173,
|
||||
0.4493206717449229,
|
||||
0.523623559737649,
|
||||
0.466984990291569,
|
||||
0.4383785007402606,
|
||||
0.5428741668225691,
|
||||
0.41135829972722604,
|
||||
0.4856611877199521,
|
||||
0.5345657307423113,
|
||||
0.5227948479641182,
|
||||
0.4046361521852423,
|
||||
0.47893904017796834,
|
||||
0.5144864118838605,
|
||||
0.4131633228780999,
|
||||
0.487466210870826
|
||||
]
|
||||
}
|
||||
],
|
||||
"known_2d_check": {
|
||||
"shape": [
|
||||
64,
|
||||
64
|
||||
],
|
||||
"ra": 10.0,
|
||||
"rr": 3.0,
|
||||
"rb": 10.0,
|
||||
"ring_sum": 279.21631227194473,
|
||||
"disk_sum": 35.52403518160772
|
||||
}
|
||||
}
|
||||
5583
tests/fixtures/contract/rule_surface.json
vendored
Normal file
5583
tests/fixtures/contract/rule_surface.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4864
tests/fixtures/contract/sphere.json
vendored
Normal file
4864
tests/fixtures/contract/sphere.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
371
tests/python/test_contract_oracle.py
Executable file
371
tests/python/test_contract_oracle.py
Executable file
@@ -0,0 +1,371 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Invariant and committed-golden tests for the Macrostep 00 Python oracle."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
import math
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
TOOLS = ROOT / "tools"
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "contract"
|
||||
sys.path.insert(0, str(TOOLS))
|
||||
|
||||
_ORACLE_SPEC = importlib.util.spec_from_file_location(
|
||||
"contract_oracle", TOOLS / "contract_oracle.py"
|
||||
)
|
||||
if _ORACLE_SPEC is None or _ORACLE_SPEC.loader is None:
|
||||
raise RuntimeError("could not load tools/contract_oracle.py")
|
||||
oracle = importlib.util.module_from_spec(_ORACLE_SPEC)
|
||||
sys.modules[_ORACLE_SPEC.name] = oracle
|
||||
_ORACLE_SPEC.loader.exec_module(oracle)
|
||||
|
||||
|
||||
def load_fixture(name: str) -> dict[str, Any]:
|
||||
try:
|
||||
with (FIXTURES / name).open("r", encoding="utf-8") as handle:
|
||||
value = json.load(handle)
|
||||
except (OSError, json.JSONDecodeError) as error:
|
||||
raise AssertionError(
|
||||
f"could not load committed fixture {name}: {error}"
|
||||
) from error
|
||||
if not isinstance(value, dict):
|
||||
raise AssertionError(f"fixture {name} is not a JSON object")
|
||||
return value
|
||||
|
||||
|
||||
class IndexAndRuleTests(unittest.TestCase):
|
||||
def test_x_fast_index_round_trip_and_signed_offsets(self) -> None:
|
||||
for shape in ((8,), (5, 3), (4, 3, 2)):
|
||||
for expected, coords in enumerate(oracle.iter_coords(shape)):
|
||||
self.assertEqual(oracle.flat_index(coords, shape), expected)
|
||||
self.assertEqual(oracle.unflatten_index(expected, shape), coords)
|
||||
self.assertEqual(
|
||||
[oracle.signed_offset(i, 8) for i in range(8)], [0, 1, 2, 3, -4, -3, -2, -1]
|
||||
)
|
||||
|
||||
def test_curve_boundaries_overshoot_and_hard_window(self) -> None:
|
||||
center, width = 0.5, 0.2
|
||||
for curve_type in (1, 2, 3):
|
||||
self.assertAlmostEqual(
|
||||
oracle.rising_curve(curve_type, center - width / 2, center, width),
|
||||
0.0,
|
||||
places=14,
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
oracle.rising_curve(curve_type, center + width / 2, center, width),
|
||||
1.0,
|
||||
places=14,
|
||||
)
|
||||
self.assertEqual(oracle.window_curve(0, 0.3, 0.3, 0.7, 0.1), 1.0)
|
||||
self.assertEqual(
|
||||
oracle.window_curve(0, math.nextafter(0.7, -math.inf), 0.3, 0.7, 0.1), 1.0
|
||||
)
|
||||
self.assertEqual(oracle.window_curve(0, 0.7, 0.3, 0.7, 0.1), 0.0)
|
||||
self.assertLess(oracle.rising_curve(7, 0.364, center, width), 0.0)
|
||||
self.assertGreater(oracle.rising_curve(7, 0.636, center, width), 1.0)
|
||||
|
||||
def test_rule_fixture_covers_every_valid_enum_triple(self) -> None:
|
||||
fixture = load_fixture("rule_surface.json")
|
||||
axes = fixture["axes"]
|
||||
self.assertEqual(axes["sigmode"], [1, 2, 3, 4])
|
||||
self.assertEqual(axes["sigtype"], list(range(10)))
|
||||
self.assertEqual(axes["mixtype"], list(range(8)))
|
||||
seen = 0
|
||||
for modes in fixture["values"]:
|
||||
self.assertEqual(len(modes), 10)
|
||||
for types in modes:
|
||||
self.assertEqual(len(types), 8)
|
||||
for surface in types:
|
||||
self.assertEqual((len(surface), len(surface[0])), (3, 3))
|
||||
self.assertTrue(
|
||||
all(math.isfinite(value) for row in surface for value in row)
|
||||
)
|
||||
seen += 1
|
||||
self.assertEqual(seen, fixture["enum_combination_count"])
|
||||
self.assertEqual(seen, 320)
|
||||
|
||||
|
||||
class KernelAndFftTests(unittest.TestCase):
|
||||
def test_complete_sampled_kernels_and_direct_convolution(self) -> None:
|
||||
fixture = load_fixture("planar_fields.json")
|
||||
for case in fixture["cases"]:
|
||||
kernels = case["kernel"]
|
||||
self.assertAlmostEqual(sum(kernels["normalized_disk"]), 1.0, places=14)
|
||||
self.assertAlmostEqual(sum(kernels["normalized_ring"]), 1.0, places=14)
|
||||
support_indices = {
|
||||
oracle.flat_index(entry["coords"], case["shape"])
|
||||
for entry in kernels["support"]
|
||||
}
|
||||
expected_support = {
|
||||
index
|
||||
for index, pair in enumerate(
|
||||
zip(kernels["raw_disk"], kernels["raw_ring"], strict=True)
|
||||
)
|
||||
if pair != (0.0, 0.0)
|
||||
}
|
||||
self.assertEqual(support_indices, expected_support)
|
||||
constant = [0.375] * oracle.product(case["shape"])
|
||||
disk = oracle.circular_convolution(
|
||||
constant, kernels["normalized_disk"], case["shape"]
|
||||
)
|
||||
ring = oracle.circular_convolution(
|
||||
constant, kernels["normalized_ring"], case["shape"]
|
||||
)
|
||||
self.assertTrue(all(abs(value - 0.375) < 1e-14 for value in disk + ring))
|
||||
known = fixture["known_2d_check"]
|
||||
self.assertAlmostEqual(known["ring_sum"], 279.216312, places=6)
|
||||
self.assertAlmostEqual(known["disk_sum"], 35.524035, places=6)
|
||||
|
||||
def test_packed_fft_bits_plans_and_convolution(self) -> None:
|
||||
fixture = load_fixture("legacy_packed_fft.json")
|
||||
self.assertEqual(
|
||||
[case["shape"] for case in fixture["cases"]], [[8], [4, 4], [4, 2, 2]]
|
||||
)
|
||||
for case in fixture["cases"]:
|
||||
for decimal, bits in zip(
|
||||
case["input_f32"]["decimal"], case["input_f32"]["bits"], strict=True
|
||||
):
|
||||
decoded = struct.unpack("<f", struct.pack("<I", int(bits, 16)))[0]
|
||||
self.assertEqual(decoded, decimal)
|
||||
self.assertLess(case["max_abs_error_to_direct"], 2e-6)
|
||||
self.assertEqual(
|
||||
len(case["convolution_f32"]["decimal"]), math.prod(case["shape"])
|
||||
)
|
||||
first_plan = case["plans"]["x_forward_butterflies"][0]["entries"]
|
||||
self.assertEqual(first_plan[0]["source"][0], 0)
|
||||
self.assertEqual(first_plan[0]["twiddle"]["bits"][0], "0x3f800000")
|
||||
# The 1-D Nx=8 stage-1 plan starts from 2-bit bit-reversed packed indices.
|
||||
first = fixture["cases"][0]["plans"]["x_forward_butterflies"][0]["entries"]
|
||||
self.assertEqual(
|
||||
[entry["source"] for entry in first], [[0, 2], [0, 2], [1, 3], [1, 3]]
|
||||
)
|
||||
|
||||
|
||||
class RandomAndInitializerTests(unittest.TestCase):
|
||||
def test_chacha12_known_block_and_word_composition(self) -> None:
|
||||
rng = oracle.ChaCha12(0)
|
||||
self.assertEqual(
|
||||
[rng.u32() for _ in range(4)],
|
||||
[0x6A9AF49B, 0x53F95507, 0x12CE1F81, 0xD583265F],
|
||||
)
|
||||
words = oracle.ChaCha12(1)
|
||||
low, high = words.u32(), words.u32()
|
||||
combined = oracle.ChaCha12(1).u64()
|
||||
self.assertEqual(combined, low | (high << 32))
|
||||
value = oracle.ChaCha12(1).float53()
|
||||
self.assertEqual(value, (combined >> 11) * 2.0**-53)
|
||||
|
||||
def test_integer_rejection_skips_incomplete_high_residue(self) -> None:
|
||||
class Scripted(oracle.ChaCha12):
|
||||
def __init__(self) -> None:
|
||||
self.values = iter([(1 << 64) - 1, 5])
|
||||
|
||||
def u64(self) -> int:
|
||||
return next(self.values)
|
||||
|
||||
# For span 2^63+1, the first scripted value is above the acceptance limit.
|
||||
self.assertEqual(Scripted().integer(0, (1 << 63) + 1), 5)
|
||||
|
||||
def test_initializer_arrays_are_topology_native_and_explicit(self) -> None:
|
||||
fixture = load_fixture("initializers.json")
|
||||
planar = fixture["planar_periodic_splats"]
|
||||
self.assertEqual(
|
||||
[entry["shape"] for entry in planar], [[12], [8, 6], [6, 5, 4]]
|
||||
)
|
||||
for entry in planar:
|
||||
self.assertEqual(len(entry["field"]), math.prod(entry["shape"]))
|
||||
self.assertTrue(set(entry["field"]) <= {0.0, 1.0})
|
||||
self.assertEqual(len(entry["splats"]), entry["count"])
|
||||
sphere = fixture["sphere_geodesic_overlays"]
|
||||
self.assertEqual(sphere["draw_count"], 1000)
|
||||
self.assertEqual(len(sphere["field"]), 6 * sphere["k"] * sphere["k"])
|
||||
self.assertTrue(all(2 <= draw["radius"] <= 7 for draw in sphere["first_draws"]))
|
||||
delayed = fixture["delayed_time_periodic_boxes"]
|
||||
self.assertEqual(delayed["depth"], 16)
|
||||
self.assertEqual(len(delayed["history"]), 16)
|
||||
self.assertTrue(all(layer == delayed["frame"] for layer in delayed["history"]))
|
||||
self.assertTrue(
|
||||
all(
|
||||
10 <= box["width"] <= 19 and 10 <= box["height"] <= 19
|
||||
for box in delayed["first_boxes"]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class DynamicsAndTopologyTests(unittest.TestCase):
|
||||
def test_integrator_startup_and_relaxation_references(self) -> None:
|
||||
fixture = load_fixture("integration.json")
|
||||
startup = fixture["ab3_startup"]
|
||||
self.assertEqual(startup["methods"], ["Euler", "AB2", "AB3"])
|
||||
dt = fixture["dt"]
|
||||
for before, derivative, after in zip(
|
||||
startup["states"][0],
|
||||
startup["derivatives"][0],
|
||||
startup["states"][1],
|
||||
strict=True,
|
||||
):
|
||||
self.assertAlmostEqual(
|
||||
after, oracle.clamp(before + dt * derivative), places=15
|
||||
)
|
||||
current, previous = startup["derivatives"][1], startup["derivatives"][0]
|
||||
expected_ab2 = [
|
||||
(3 * now - old) / 2 for now, old in zip(current, previous, strict=True)
|
||||
]
|
||||
self.assertEqual(startup["ab2_combination"], expected_ab2)
|
||||
for stage in fixture["rk4"]["stage_states"]:
|
||||
self.assertTrue(all(0.0 <= value <= 1.0 for value in stage))
|
||||
stage_state = fixture["rk4_relaxation_stage_state"]
|
||||
step_origin = fixture["rk4_relaxation_step_origin"]
|
||||
self.assertEqual(stage_state["derivatives"][0], step_origin["derivatives"][0])
|
||||
self.assertNotEqual(
|
||||
stage_state["derivatives"][1], step_origin["derivatives"][1]
|
||||
)
|
||||
self.assertNotEqual(stage_state["next"], step_origin["next"])
|
||||
|
||||
def test_all_multiscale_combinations_and_composition_equations(self) -> None:
|
||||
fixture = load_fixture("multiscale.json")
|
||||
cases = fixture["cases"]
|
||||
triples = {
|
||||
(case["dynamics"], case["interpretation"], case["composition"])
|
||||
for case in cases
|
||||
}
|
||||
self.assertEqual(len(cases), 12)
|
||||
self.assertEqual(len(triples), 12)
|
||||
for case in cases:
|
||||
if case["composition"] == "ordered_clamped_sum":
|
||||
state = fixture["field"][:]
|
||||
for increment in case["increments"]:
|
||||
state = [
|
||||
oracle.clamp(value + change)
|
||||
for value, change in zip(state, increment, strict=True)
|
||||
]
|
||||
self.assertEqual(state, case["next"])
|
||||
elif case["composition"] == "mean_increment":
|
||||
expected = [
|
||||
oracle.clamp(value + sum(changes) / 3.0)
|
||||
for value, changes in zip(
|
||||
fixture["field"], zip(*case["increments"]), strict=True
|
||||
)
|
||||
]
|
||||
self.assertEqual(expected, case["next"])
|
||||
else:
|
||||
self.assertEqual(case["next"], case["clamp_stages"][-1])
|
||||
|
||||
def test_corrected_and_legacy_sphere_invariants(self) -> None:
|
||||
fixture = load_fixture("sphere.json")
|
||||
geometry = fixture["geometry"]
|
||||
self.assertTrue(
|
||||
all(area > 0.0 and math.isfinite(area) for area in geometry["areas"])
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
geometry["total_area"], geometry["analytic_area"], places=12
|
||||
)
|
||||
corrected = fixture["models"]["corrected"]
|
||||
legacy = fixture["models"]["legacy"]
|
||||
for channel in ("m", "n"):
|
||||
self.assertTrue(
|
||||
all(
|
||||
abs(value - 0.375) < 5e-15
|
||||
for value in corrected["constant_field"][channel]
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
any(abs(value - 0.375) > 1e-3 for value in legacy["constant_field"]["m"])
|
||||
)
|
||||
self.assertEqual(corrected["disk_denominators"], corrected["visited_disk_sums"])
|
||||
self.assertNotEqual(legacy["disk_denominators"], legacy["visited_disk_sums"])
|
||||
for mapping in fixture["legacy_side_and_mask_map"]:
|
||||
if mapping["region"].startswith("masked"):
|
||||
self.assertIsNone(mapping["mapped"])
|
||||
else:
|
||||
self.assertIsNotNone(mapping["mapped"])
|
||||
for model in (corrected, legacy):
|
||||
expected_length = 6 * fixture["k"] * fixture["k"]
|
||||
self.assertEqual(len(model["m"]), expected_length)
|
||||
self.assertEqual(len(model["constant_field"]["s"]), expected_length)
|
||||
self.assertEqual(
|
||||
len(model["constant_field"]["next_discrete"]), expected_length
|
||||
)
|
||||
self.assertEqual(
|
||||
len(model["constant_field"]["next_smooth"]), expected_length
|
||||
)
|
||||
self.assertTrue(
|
||||
all(
|
||||
0.0 <= value <= 1.0
|
||||
for value in model["next_discrete"] + model["next_smooth"]
|
||||
)
|
||||
)
|
||||
|
||||
def test_delayed_time_causal_shells_and_updates(self) -> None:
|
||||
fixture = load_fixture("delayed_time.json")
|
||||
evaluation = fixture["evaluation"]
|
||||
self.assertEqual(evaluation["latest"], (fixture["head"] - 1) % fixture["depth"])
|
||||
for shell in fixture["shell_offsets_by_rounded_age"]:
|
||||
self.assertEqual(
|
||||
shell["selected_layer"],
|
||||
(evaluation["latest"] - shell["age"]) % fixture["depth"],
|
||||
)
|
||||
stencil = evaluation["stencil"]
|
||||
expected_m = (
|
||||
sum(
|
||||
(((evaluation["latest"] - entry["delay"]) % fixture["depth"]) / 15.0)
|
||||
* entry["disk"]
|
||||
for entry in stencil["entries"]
|
||||
)
|
||||
/ stencil["disk_sum"]
|
||||
)
|
||||
expected_n = (
|
||||
sum(
|
||||
(((evaluation["latest"] - entry["delay"]) % fixture["depth"]) / 15.0)
|
||||
* entry["ring"]
|
||||
for entry in stencil["entries"]
|
||||
)
|
||||
/ stencil["ring_sum"]
|
||||
)
|
||||
self.assertTrue(
|
||||
all(abs(value - expected_m) < 1e-14 for value in evaluation["m"])
|
||||
)
|
||||
self.assertTrue(
|
||||
all(abs(value - expected_n) < 1e-14 for value in evaluation["n"])
|
||||
)
|
||||
latest_value = evaluation["latest"] / 15.0
|
||||
for target, smooth in zip(
|
||||
evaluation["s"], evaluation["next_smooth"], strict=True
|
||||
):
|
||||
self.assertAlmostEqual(
|
||||
smooth, oracle.clamp(latest_value + 0.1 * (2 * target - 1)), places=15
|
||||
)
|
||||
|
||||
|
||||
class CommittedFixtureTests(unittest.TestCase):
|
||||
def test_manifest_hashes(self) -> None:
|
||||
manifest = load_fixture("manifest.json")
|
||||
self.assertTrue(manifest["standard_library_only"])
|
||||
for entry in manifest["files"]:
|
||||
content = (FIXTURES / entry["path"]).read_bytes()
|
||||
self.assertEqual(len(content), entry["bytes"])
|
||||
self.assertEqual(hashlib.sha256(content).hexdigest(), entry["sha256"])
|
||||
|
||||
def test_generator_check_mode(self) -> None:
|
||||
completed = subprocess.run(
|
||||
[sys.executable, str(TOOLS / "generate_contract_fixtures.py"), "--check"],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
self.assertEqual(completed.returncode, 0, completed.stdout + completed.stderr)
|
||||
self.assertIn("verified 11 contract fixture files", completed.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user