From 0ea60cbf732109bfba5c40b6cf991efc9c08bfc6 Mon Sep 17 00:00:00 2001 From: mtnel24 Date: Sat, 21 Mar 2026 18:42:46 -0500 Subject: [PATCH 1/2] Add docstring,comments and helpful print statement to test_transform_consistsent_with_wf --- tests/unit/test_evaluate_gradients_threaded.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_evaluate_gradients_threaded.py b/tests/unit/test_evaluate_gradients_threaded.py index f940c6a5..3c1b50de 100644 --- a/tests/unit/test_evaluate_gradients_threaded.py +++ b/tests/unit/test_evaluate_gradients_threaded.py @@ -5,6 +5,7 @@ def test_transform_consistent_with_wf(H2_casci): + """Test that evaluate_gradient_threaded works when given states with different numbers of determinants""" from pyqmc.method.ensemble_optimization_wfbywf import StochasticReconfigurationWfbyWf from pyqmc.method.ensemble_optimization_threaded import evaluate_gradients_threaded mol, mf, mc = H2_casci @@ -14,7 +15,7 @@ def test_transform_consistent_with_wf(H2_casci): energy = pyq.EnergyAccumulator(mol) sr_accumulator = [] - tol = 1e-20 + tol = 1e-20 # With tol = 1e-20 state 0 has 4 determinants whereas state 1 will have 3 wfs = [] for i in range(2): @@ -36,6 +37,8 @@ def test_transform_consistent_with_wf(H2_casci): [[copy.deepcopy(configs) for _ in range(2)] for _ in range(len(sr_accumulator[wfi]))] for wfi in range(2) ] + for i,wf in enumerate(wfs): + print(f"For wf{i} {len(wf.parameters['det_coeff']) = }") with ProcessPoolExecutor() as executor: _, data_unweighted, configs = pyqmc.method.sample_many.sample_overlap( wfs, From 4fb52ebb3e456b67c4627cf03fbc0a5bdbe67642 Mon Sep 17 00:00:00 2001 From: mtnel24 Date: Sat, 21 Mar 2026 18:43:20 -0500 Subject: [PATCH 2/2] Reduce number of configurations to one so test can run faster --- tests/unit/test_evaluate_gradients_threaded.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/unit/test_evaluate_gradients_threaded.py b/tests/unit/test_evaluate_gradients_threaded.py index 3c1b50de..8c6eb959 100644 --- a/tests/unit/test_evaluate_gradients_threaded.py +++ b/tests/unit/test_evaluate_gradients_threaded.py @@ -18,7 +18,6 @@ def test_transform_consistent_with_wf(H2_casci): tol = 1e-20 # With tol = 1e-20 state 0 has 4 determinants whereas state 1 will have 3 wfs = [] for i in range(2): - wf, to_opt = pyq.generate_slater(mol, mf, mc=mcs[i], optimize_determinants=True, tol = tol) wfs.append(wf) sr_accumulator.append( @@ -31,8 +30,7 @@ def test_transform_consistent_with_wf(H2_casci): ) ] ) - - configs = pyq.initial_guess(mol, 100) + configs = pyq.initial_guess(mol, 1) configs_ensemble = [ [[copy.deepcopy(configs) for _ in range(2)] for _ in range(len(sr_accumulator[wfi]))] for wfi in range(2)