Skip to content

Commit

Permalink
tweak docstring for units
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed May 17, 2024
1 parent c01343e commit 255bc54
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pymatgen/core/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ def to(self, new_unit: str | Unit) -> Self:
A ArrayWithUnit object in the new unit.
Example usage:
>>> e = EnergyArray([1, 1.1], "Ha")
>>> e.to("eV")
>>> energy = EnergyArray([1, 1.1], "Ha")
>>> energy.to("eV")
array([ 27.21138386, 29.93252225]) eV
"""
return type(self)(
Expand All @@ -658,17 +658,17 @@ def as_base_units(self):
"""
return self.to(self.unit.as_base_units[0])

# TODO abstract base class property?
@property
def supported_units(self) -> dict:
# TODO abstract base class property?
"""Supported units for specific unit type."""
if self.unit_type is None:
raise RuntimeError("Cannot get supported unit for None.")

return ALL_UNITS[self.unit_type]

# TODO abstract base class method?
def conversions(self) -> str:
# TODO abstract base class method?
"""Get a string showing the available conversions.
Useful tool in interactive mode.
"""
Expand Down

0 comments on commit 255bc54

Please sign in to comment.