Skip to content

FloatWithUnit should overwrite __rtruediv__ #4495

@DanielYang59

Description

@DanielYang59

Currently we don't overwrite __rtruediv__ for FloatWithUnit, so when do float / FloatWithUnit the unit would be lost:

from pymatgen.core.units import FloatWithUnit


x = FloatWithUnit(5, "MPa")
y = 5 / x

print(y)
print(type(y))
1.0
<class 'float'>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions