aoptk.chemical
Classes
Data structure representing a chemical. |
Module Contents
- class aoptk.chemical.Chemical(name: str)[source]
Data structure representing a chemical.
Instances are considered equal when their name values are equal. The class implements
__hash__so instances can be used as dict keys or set members.- property heading: str | None[source]
Heading or canonical name of the chemical.
Only available after normalization or if it is set manually after object instantiation.
- Returns:
Canonical name of the chemical or None
- Return type:
str | None
- similar(other: Chemical) bool[source]
Test if two chemicals are similar, so if any of their names match.
Chemicals that are equal are also always similar.
- __eq__(other: object) bool[source]
Compare two Chemical instances for equality.
Returns
NotImplementedwhen other is not a Chemical, allowing Python to try reflected comparisons or fall back toFalse.
- __eq_object(other: object) bool[source]
Private helper to compare a Chemical to a non-Chemical object.
This is called from
__eq__()whenotheris not aChemical. The method compares the string representation ofotherto this instance’s heading (when present) and name.