Download code/test_t4_structural_dynamics_v1.py from HaomingLuo/AgentFEM-Structural-Dynamics-Virtual-Sensing: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/datasets/HaomingLuo/AgentFEM-Structural-Dynamics-Virtual-Sensing/resolve/main/code/test_t4_structural_dynamics_v1.py
- Command line
-
hf download hf://datasets/HaomingLuo/AgentFEM-Structural-Dynamics-Virtual-Sensing/code/test_t4_structural_dynamics_v1.py
-
curl -L -o test_t4_structural_dynamics_v1.py https://huggingface.co/datasets/HaomingLuo/AgentFEM-Structural-Dynamics-Virtual-Sensing/resolve/main/code/test_t4_structural_dynamics_v1.py
1.76 kB
| from __future__ import annotations | |
| from collections import Counter | |
| from pathlib import Path | |
| import h5py | |
| import numpy as np | |
| from src.t4_structural_dynamics_v1 import ( | |
| CASE_DIR, | |
| case_config, | |
| configuration_design, | |
| load_config, | |
| valid_case_file, | |
| ) | |
| def test_t4_v1_design_has_grouped_splits_and_explicit_ood_roles(): | |
| rows = configuration_design() | |
| assert len(rows) == 128 | |
| assert len({row["case_id"] for row in rows}) == 128 | |
| assert Counter(row["split"] for row in rows) == { | |
| "train": 96, | |
| "validation": 16, | |
| "test": 16, | |
| } | |
| assert Counter(row["protocol_role"] for row in rows) == { | |
| "id": 120, | |
| "excitation_ood": 4, | |
| "parameter_ood": 4, | |
| } | |
| assert all(len(row["excitations"]) == 4 for row in rows) | |
| def test_t4_v1_case_configuration_scales_sensors_with_geometry(): | |
| global_config = load_config() | |
| row = configuration_design(global_config)[0] | |
| config = case_config(global_config, row) | |
| length = config["geometry"]["length_m"] | |
| height = config["geometry"]["height_m"] | |
| assert np.allclose( | |
| config["sensors"], | |
| [[fraction * length, 0.5 * height] for fraction in (0.2, 0.4, 0.6, 0.8, 1.0)], | |
| ) | |
| def test_t4_v1_first_production_case_is_complete_and_finite(): | |
| path = CASE_DIR / "config_0000.h5" | |
| assert valid_case_file(path) | |
| with h5py.File(path, "r") as h5: | |
| assert h5.attrs["split"] == "train" | |
| assert len(h5["trajectories"]) == 4 | |
| for trajectory in h5["trajectories"].values(): | |
| assert trajectory["sensor_displacement_m"].shape == (4001, 5) | |
| assert trajectory["fields/displacement_m"].shape == (201, 245, 3) | |
| assert np.all(np.isfinite(trajectory["sensor_displacement_m"][...])) | |