Skip to content

Commit 3dc07df

Browse files
mattwthompsonYoshanuikabundi
authored andcommitted
Hacks for Pint compatibility
1 parent 1696189 commit 3dc07df

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

openff/toolkit/topology/molecule.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def __init__(
268268

269269
# Use the setter here, since it will handle either ints or Quantities
270270
# and it is designed to quickly process ints
271-
self.formal_charge = formal_charge
271+
self.formal_charge = formal_charge # type: ignore[assignment]
272272
self._is_aromatic = is_aromatic
273273
self._stereochemistry = stereochemistry
274274
if name is None:
@@ -308,9 +308,13 @@ def to_dict(self) -> dict[str, Union[None, str, int, bool, dict[Any, Any]]]:
308308
"""
309309
# TODO: Should this be implicit in the atom ordering when saved?
310310
# atom_dict['molecule_atom_index'] = self._molecule_atom_index
311+
312+
# trust that the unit is e
313+
formal_charge: int = self._formal_charge.m # type: ignore
314+
311315
return {
312316
"atomic_number": self._atomic_number,
313-
"formal_charge": self._formal_charge.m, # Trust that the unit is e
317+
"formal_charge": formal_charge,
314318
"is_aromatic": self._is_aromatic,
315319
"stereochemistry": self._stereochemistry,
316320
"name": self._name,
@@ -5960,12 +5964,7 @@ def __init__(
59605964
for id_component, uniqueness_component in zip(identifier, scheme.uniqueness_criteria):
59615965
setattr(self, uniqueness_component, id_component)
59625966

5963-
<<<<<<< HEAD
5964-
59655967
def to_dict(self) -> dict[str, tuple[str | int, ...] | Sequence[int]]:
5966-
=======
5967-
def to_dict(self) -> dict[str, tuple[str | int, ...] | Sequence[int]]:
5968-
>>>>>>> 549a39bc (Fix)
59695968
"""Serialize this object to a basic dict of strings and lists of ints.
59705969
59715970
Keys and values align with parameters used to initialize the :class:`HierarchyElement` class.

openff/toolkit/utils/builtin_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def assign_partial_charges(
131131
partial_charges = [0.0] * molecule.n_atoms
132132

133133
elif partial_charge_method == "formal_charge":
134-
partial_charges = [float(atom.formal_charge.m) for atom in molecule.atoms]
134+
partial_charges = [float(atom.formal_charge.m) for atom in molecule.atoms] # type: ignore
135135

136136
molecule.partial_charges = Quantity(partial_charges, unit.elementary_charge)
137137

0 commit comments

Comments
 (0)