Download tests/test_t2_denim_capability_v4.py from HaomingLuo/AgentFEM-Material-Loading-Memory: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/datasets/HaomingLuo/AgentFEM-Material-Loading-Memory/resolve/main/tests/test_t2_denim_capability_v4.py
- Command line
-
hf download hf://datasets/HaomingLuo/AgentFEM-Material-Loading-Memory/tests/test_t2_denim_capability_v4.py
-
curl -L -o test_t2_denim_capability_v4.py https://huggingface.co/datasets/HaomingLuo/AgentFEM-Material-Loading-Memory/resolve/main/tests/test_t2_denim_capability_v4.py
3.15 kB
| from __future__ import annotations | |
| from collections import Counter, defaultdict | |
| import numpy as np | |
| from src.generate_t2_denim_capability_v4 import ( | |
| FULL_3D_FAMILIES, | |
| RESOLUTIONS, | |
| design, | |
| solve_row, | |
| ) | |
| def test_v4_design_counts_and_unique_ids(): | |
| rows = design() | |
| assert len(rows) == 1000 | |
| assert len({row["case_id"] for row in rows}) == 1000 | |
| assert Counter(row["cohort"] for row in rows) == { | |
| "long_cycle": 300, | |
| "full_3d_nonproportional": 300, | |
| "structure_derived": 200, | |
| "discretization_and_observation": 200, | |
| } | |
| assert Counter(row["path_family"] for row in rows if row["cohort"] == "full_3d_nonproportional") == { | |
| family: 50 for family in FULL_3D_FAMILIES | |
| } | |
| def test_v4_resolution_groups_are_complete_and_isolated(): | |
| rows = [row for row in design() if row["cohort"] == "discretization_and_observation"] | |
| grouped = defaultdict(list) | |
| for row in rows: | |
| grouped[row["group_id"]].append(row) | |
| assert len(grouped) == 50 | |
| for values in grouped.values(): | |
| assert tuple(sorted(row["points"] for row in values)) == RESOLUTIONS | |
| assert len({row["split"] for row in values}) == 1 | |
| assert len({row["path_seed"] for row in values}) == 1 | |
| assert len({row["maximum_equivalent_strain"] for row in values}) == 1 | |
| def test_v4_long_cycle_split_is_true_horizon_ood(): | |
| rows = [row for row in design() if row["cohort"] == "long_cycle"] | |
| assert {row["cycle_count"] for row in rows if row["split"] == "train_long_cycle"} == {10, 25} | |
| assert {row["cycle_count"] for row in rows if row["split"] == "validation_long_cycle"} == {50} | |
| assert {row["cycle_count"] for row in rows if row["split"] == "test_long_cycle_ood"} == {100} | |
| def test_v4_material_point_smoke_without_structure_solver(): | |
| rows = design() | |
| selected = ( | |
| next(row for row in rows if row["cohort"] == "long_cycle"), | |
| next(row for row in rows if row["cohort"] == "full_3d_nonproportional"), | |
| next(row for row in rows if row["cohort"] == "discretization_and_observation"), | |
| ) | |
| for row in selected: | |
| arrays, metrics = solve_row(row, {}) | |
| assert metrics["all_finite"] | |
| assert metrics["minimum_peeq_increment"] >= -1.0e-12 | |
| assert metrics["maximum_yield_surface_relative_residual"] < 1.0e-8 | |
| assert arrays["strain"].shape == (row["points"], 6) | |
| assert arrays["stress_pa"].shape == (row["points"], 6) | |
| observed, _ = solve_row(selected[-1], {}) | |
| assert observed["observation_mask"].dtype == np.uint8 | |
| assert observed["observation_mask"][0] == 1 | |
| assert observed["observation_mask"][-1] == 1 | |
| def test_every_full_3d_family_is_symmetric_and_integrable(): | |
| rows = [row for row in design() if row["cohort"] == "full_3d_nonproportional"] | |
| for family in FULL_3D_FAMILIES: | |
| row = next(value for value in rows if value["path_family"] == family) | |
| arrays, metrics = solve_row(row, {}) | |
| strain = arrays["strain"] | |
| assert np.isfinite(strain).all() | |
| assert metrics["all_finite"] | |
| assert metrics["maximum_yield_surface_relative_residual"] < 1.0e-8 | |