This issue is a Codex global repository scan finding for deepmodeling/reacnetgenerator at commit 4fa8e2b.
The ASE custom-cutoff tests currently do not fail if pair-specific custom cutoffs are ignored.
Relevant code:
|
"inputfilename", |
|
"atomname", |
|
"stepinterval", |
|
"nproc", |
|
"pbc", |
|
"cell", |
|
"use_ase", |
|
"ase_cutoff_mult", |
|
"custom_cutoffs", |
|
], |
|
["N", "atomtype", "step", "timestep", "temp1it", "moleculetempfilename"], |
|
) |
|
self._parsed_custom_cutoffs = self._parse_custom_cutoffs(self.custom_cutoffs) |
|
def test_custom_cutoffs_override(self, detect_instance): |
|
"""Test that custom cutoffs override global settings.""" |
|
# Modify the detect instance to have custom cutoffs |
|
detect_instance.rng.custom_cutoffs = "H-O:1.0" # Very short cutoff |
|
|
|
# Create a simple water molecule where H-O distance is ~1.0 Angstrom |
|
atoms = Atoms( |
|
"H2O", positions=[[0.5, 0.0, 0.0], [-0.5, 0.0, 0.0], [0.0, 0.0, 0.0]] |
|
) # H-O distance is 0.5 |
|
cell = np.eye(3) * 10 |
|
|
|
bond, _bondlevel = detect_instance._getbondfromase(atoms, cell) |
|
|
|
# With a 1.0 cutoff, H-O should still be bonded |
|
# Check that oxygen is bonded to at least one hydrogen |
|
assert 0 in bond[2] or 1 in bond[2] # O (index 2) bonded to H (index 0 or 1) |
|
def test_ase_with_custom_cutoffs_integration(self): |
|
"""Integration test for ASE mode with custom cutoffs.""" |
|
# Create a temporary file with a simple water molecule |
|
water_file = "test_water.dump" |
|
with open(water_file, "w") as f: |
|
f.write("""ITEM: TIMESTEP |
|
0 |
|
ITEM: NUMBER OF ATOMS |
|
3 |
|
ITEM: BOX BOUNDS pp pp pp |
|
0.0 10.0 |
|
0.0 10.0 |
|
0.0 10.0 |
|
ITEM: ATOMS id type x y z |
|
1 1 0.757 0.586 0.0 |
|
2 1 -0.757 0.586 0.0 |
|
3 2 0.0 0.0 0.0 |
|
""") |
|
|
|
rng = ReacNetGenerator( |
|
inputfiletype="lammpsdumpfile", |
|
inputfilename=water_file, |
|
atomname=["H", "O"], |
|
pbc=True, |
|
use_ase=True, |
|
custom_cutoffs="H-O:1.5", # Custom cutoff for H-O bonds |
|
) |
|
|
|
# Run the detection process |
|
detect_class = _DetectLAMMPSdump.gettype(rng) |
|
detect_class.detect() |
|
|
|
# Should have processed the file |
|
assert hasattr(detect_class, "temp1it") |
|
assert detect_class.temp1it > 0 |
Why the current tests are weak:
_DetectCrd.__init__() parses self.custom_cutoffs into self._parsed_custom_cutoffs once at construction time.
test_custom_cutoffs_override mutates detect_instance.rng.custom_cutoffs after the detector was already constructed, so it does not update self._parsed_custom_cutoffs.
- The geometry in that test has 0.5 A H-O distances, which are expected to bond under the default natural cutoff anyway.
- The integration test only checks that the detection ran and produced
temp1it > 0, not that the custom cutoff changed the resulting bonds/molecules.
Impact:
A regression that completely ignores --ase-pair-cutoffs can still pass the current tests.
Suggested fix:
Build the detector with custom cutoffs before initialization, and use a geometry where default cutoffs and custom cutoffs produce different bond graphs. Assert the actual bond lists or molecule count, not just that detection completed.
This issue is a Codex global repository scan finding for deepmodeling/reacnetgenerator at commit 4fa8e2b.
The ASE custom-cutoff tests currently do not fail if pair-specific custom cutoffs are ignored.
Relevant code:
reacnetgenerator/reacnetgenerator/_detect.py
Lines 276 to 288 in 4fa8e2b
reacnetgenerator/tests/test_detect.py
Lines 198 to 213 in 4fa8e2b
reacnetgenerator/tests/test_ase.py
Lines 182 to 216 in 4fa8e2b
Why the current tests are weak:
_DetectCrd.__init__()parsesself.custom_cutoffsintoself._parsed_custom_cutoffsonce at construction time.test_custom_cutoffs_overridemutatesdetect_instance.rng.custom_cutoffsafter the detector was already constructed, so it does not updateself._parsed_custom_cutoffs.temp1it > 0, not that the custom cutoff changed the resulting bonds/molecules.Impact:
A regression that completely ignores
--ase-pair-cutoffscan still pass the current tests.Suggested fix:
Build the detector with custom cutoffs before initialization, and use a geometry where default cutoffs and custom cutoffs produce different bond graphs. Assert the actual bond lists or molecule count, not just that detection completed.