Files
ResearchProject/FESurrogateModelTutorial/tests/test_sampling.py
T
2026-05-21 17:03:51 +09:00

20 lines
752 B
Python

import pandas as pd
from femsurrogate.data.bounds import DEFAULT_PARAMETER_BOUNDS
from femsurrogate.data.sampling import generate_lhs_samples
def test_lhs_samples_are_reproducible_for_fixed_seed():
first = generate_lhs_samples(DEFAULT_PARAMETER_BOUNDS, n=8, seed=20260521)
second = generate_lhs_samples(DEFAULT_PARAMETER_BOUNDS, n=8, seed=20260521)
pd.testing.assert_frame_equal(first, second)
def test_lhs_samples_have_expected_columns_and_bounds():
samples = generate_lhs_samples(DEFAULT_PARAMETER_BOUNDS, n=16, seed=20260521)
assert list(samples.columns) == list(DEFAULT_PARAMETER_BOUNDS)
for column, bounds in DEFAULT_PARAMETER_BOUNDS.items():
assert samples[column].between(bounds.lower, bounds.upper).all()