Skip to content

Commit

Permalink
Allow floating point numbers for multiplicities
Browse files Browse the repository at this point in the history
  • Loading branch information
awvwgk committed Aug 3, 2023
1 parent c9e308c commit 6048adf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions qcelemental/models/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Molecule(ProtoModel):
description="Additional comments for this molecule. Intended for pure human/user consumption and clarity.",
)
molecular_charge: float = Field(0.0, description="The net electrostatic charge of the molecule.") # type: ignore
molecular_multiplicity: int = Field(1, description="The total multiplicity of the molecule.") # type: ignore
molecular_multiplicity: Union[int, float] = Field(1, description="The total multiplicity of the molecule.") # type: ignore

# Atom data
masses_: Optional[Array[float]] = Field( # type: ignore
Expand Down Expand Up @@ -251,7 +251,7 @@ class Molecule(ProtoModel):
"if not provided (and :attr:`~qcelemental.models.Molecule.fragments` are specified).",
shape=["nfr"],
)
fragment_multiplicities_: Optional[List[int]] = Field( # type: ignore
fragment_multiplicities_: Optional[List[Union[int, float]]] = Field( # type: ignore
None,
description="The multiplicity of each fragment in the :attr:`~qcelemental.models.Molecule.fragments` list. The index of this "
"list matches the 0-index indices of :attr:`~qcelemental.models.Molecule.fragments` list. Will be filled in based on a set of "
Expand Down Expand Up @@ -784,6 +784,14 @@ def get_hash(self):
data = float_prep(data, CHARGE_NOISE)
elif field == "molecular_charge":
data = float_prep(data, CHARGE_NOISE)
elif field == "fragment_multiplicities":
if len(data) > 0 and isinstance(data[0], float):
raise RuntimeError(data)
data = float_prep(data, CHARGE_NOISE)
elif field == "molecular_multiplicity":
if isinstance(data, float):
raise RuntimeError(data)
data = float_prep(data, CHARGE_NOISE)
elif field == "masses":
data = float_prep(data, MASS_NOISE)

Expand Down

0 comments on commit 6048adf

Please sign in to comment.