Found by Codex global repository scan of deepmodeling/dpgen2 at commit 2679611a3704f5c2646c8cb353e34177518db758.
The CALYPSO task-group schema marks atomic_number and distance_of_ions as optional:
|
def caly_task_grp_args(): |
|
return [ |
|
Argument("numb_of_species", int, optional=False, doc="number of species."), |
|
Argument( |
|
"name_of_atoms", |
|
list, |
|
optional=False, |
|
doc="name of atoms.", |
|
), |
|
Argument( |
|
"atomic_number", |
|
list, |
|
optional=True, |
|
doc="atomic number of each element.", |
|
), |
|
Argument( |
|
"numb_of_atoms", |
|
list, |
|
optional=False, |
|
doc="number of each atom.", |
|
), |
|
Argument( |
|
"distance_of_ions", |
|
[list, dict], |
|
optional=True, |
|
doc="the distance matrix between different elements.", |
CalyTaskGroup.set_params only infers atomic_number for the nested random-choice form; otherwise it can leave self.atomic_number = None and self.distance_of_ions = None:
|
self.atomic_number = [atomic_symbols.index(i) for i in self.name_of_atoms] |
|
else: |
|
self.name_of_atoms = name_of_atoms |
|
self.atomic_number = atomic_number |
|
|
|
if isinstance(distance_of_ions, dict): |
|
updated_table = copy.deepcopy(covalent_radii) |
|
for key, value in distance_of_ions.items(): |
|
updated_table[atomic_number_map[key]] = value |
|
|
|
temp_distance_mtx = np.zeros((numb_of_species, numb_of_species)) |
|
for i in range(numb_of_species): |
|
for j in range(numb_of_species): |
|
temp_distance_mtx[i][j] = round( |
|
updated_table[atomic_number_map[self.name_of_atoms[i]]] * 0.7 |
|
+ updated_table[atomic_number_map[self.name_of_atoms[j]]] * 0.7, |
|
2, |
|
) |
|
self.distance_of_ions = temp_distance_mtx |
|
else: |
|
self.distance_of_ions = distance_of_ions |
make_calypso_input later treats both values as required, calling len(atomic_number) and asserting that distance_of_ions has a square matrix shape:
|
distance_of_ions = np.array(distance_of_ions) |
|
assert ( |
|
numb_of_species |
|
== len(name_of_atoms) |
|
== len(atomic_number) |
|
== len(numb_of_atoms) |
|
), f"{numb_of_species:}, {name_of_atoms:} {atomic_number:} {numb_of_atoms:}" |
|
assert distance_of_ions.shape == ( |
|
numb_of_species, |
|
numb_of_species, |
|
), f"{distance_of_ions.shape} {numb_of_species:}" |
A normalized config that omits these optional fields can crash late during task generation instead of receiving defaults or a clear validation error.
Suggested fix: either make these fields required in the schema, infer them for all supported name_of_atoms forms, or fail validation with an actionable message before make_calypso_input is called.
Found by Codex global repository scan of
deepmodeling/dpgen2at commit2679611a3704f5c2646c8cb353e34177518db758.The CALYPSO task-group schema marks
atomic_numberanddistance_of_ionsas optional:dpgen2/dpgen2/exploration/task/make_task_group_from_config.py
Lines 348 to 373 in 2679611
CalyTaskGroup.set_paramsonly infersatomic_numberfor the nested random-choice form; otherwise it can leaveself.atomic_number = Noneandself.distance_of_ions = None:dpgen2/dpgen2/exploration/task/caly_task_group.py
Lines 144 to 164 in 2679611
make_calypso_inputlater treats both values as required, callinglen(atomic_number)and asserting thatdistance_of_ionshas a square matrix shape:dpgen2/dpgen2/exploration/task/calypso/caly_input.py
Lines 271 to 281 in 2679611
A normalized config that omits these optional fields can crash late during task generation instead of receiving defaults or a clear validation error.
Suggested fix: either make these fields required in the schema, infer them for all supported
name_of_atomsforms, or fail validation with an actionable message beforemake_calypso_inputis called.