Skip to content

Commit

Permalink
:param to google-style
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Sep 13, 2023
1 parent 819b657 commit 47f1ed7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
41 changes: 24 additions & 17 deletions pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,12 +977,15 @@ def get_vbm_cbm(fermi):
# it is actually a metal
return self.efermi

def get_potcars(self, path):
def get_potcars(self, path: str | Path) -> Potcar | None:
"""
:param path: Path to search for POTCARs
Returns the POTCAR from the specified path.
Args:
path (str): The path to search for POTCARs.
Returns:
Potcar from path.
Potcar | None: The POTCAR from the specified path.
"""

def get_potcar_in_path(p):
Expand Down Expand Up @@ -1030,7 +1033,8 @@ def get_trajectory(self):

def update_potcar_spec(self, path):
"""
:param path: Path to search for POTCARs
Args:
path: Path to search for POTCARs
Returns:
Potcar spec from path.
Expand Down Expand Up @@ -2359,8 +2363,9 @@ def read_corrections(self, reverse=True, terminate_on_match=True):
Reads the dipol qudropol corrections into the
Outcar.data["dipol_quadrupol_correction"].
:param reverse: Whether to start from end of OUTCAR.
:param terminate_on_match: Whether to terminate once match is found.
Args:
reverse (bool): Whether to start from end of OUTCAR. Defaults to True.
terminate_on_match (bool): Whether to terminate once match is found. Defaults to True.
"""
patterns = {"dipol_quadrupol_correction": r"dipol\+quadrupol energy correction\s+([\d\-\.]+)"}
self.read_pattern(
Expand Down Expand Up @@ -3353,19 +3358,21 @@ def write_file(self, file_name, vasp4_compatible=False):
vasp4_compatible (bool): True if the format is vasp4 compatible
"""

def _print_fortran_float(f):
def _print_fortran_float(flt):
"""
Fortran codes print floats with a leading zero in scientific
notation. When writing CHGCAR files, we adopt this convention
to ensure written CHGCAR files are byte-to-byte identical to
their input files as far as possible.
:param f: float
Args:
flt (float): Float to print.
Returns:
str.
str: String representation of float in Fortran format.
"""
s = f"{f:.10E}"
if f >= 0:
s = f"{flt:.10E}"
if flt >= 0:
return f"0.{s[0]}{s[2:12]}E{int(s[13:]) + 1:+03}"
return f"-.{s[1]}{s[3:13]}E{int(s[14:]) + 1:+03}"

Expand Down Expand Up @@ -3429,10 +3436,10 @@ def __init__(self, poscar, data):

@classmethod
def from_file(cls, filename, **kwargs):
"""
Reads a LOCPOT file.
"""Read a LOCPOT file.
:param filename: Filename
Args:
filename (str): Path to LOCPOT file.
Returns:
Locpot
Expand Down Expand Up @@ -3466,10 +3473,10 @@ def __init__(self, poscar, data, data_aug=None):

@staticmethod
def from_file(filename: str):
"""
Read a CHGCAR file.
"""Read a CHGCAR file.
:param filename: Filename
Args:
filename (str): Path to CHGCAR file.
Returns:
Chgcar
Expand Down
15 changes: 9 additions & 6 deletions pymatgen/util/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,15 @@ def stream_has_colors(stream):


def transformation_to_string(matrix, translation_vec=(0, 0, 0), components=("x", "y", "z"), c="", delim=","):
"""Convenience method. Given matrix returns string, e.g. x+2y+1/4
:param matrix
:param translation_vec
:param components: either ('x', 'y', 'z') or ('a', 'b', 'c')
:param c: optional additional character to print (used for magmoms)
:param delim: delimiter.
"""Convenience method. Given matrix returns string, e.g. x+2y+1/4.
Args:
matrix: A 3x3 matrix.
translation_vec: A 3-element tuple representing the translation vector. Defaults to (0, 0, 0).
components: A tuple of 3 strings representing the components. Either ('x', 'y', 'z') or ('a', 'b', 'c').
Defaults to ('x', 'y', 'z').
c: An optional additional character to print (used for magmoms). Defaults to "".
delim: A delimiter. Defaults to ",".
Returns:
xyz string.
Expand Down

0 comments on commit 47f1ed7

Please sign in to comment.