From af2ed4db02341d6f7f2730a5219f88b4ec7d717b Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Tue, 14 Nov 2023 19:49:41 -0800 Subject: [PATCH] fix doc str indentation --- .../connectivity/connected_components.py | 37 +++++++++++-------- .../coordination_geometry_finder.py | 6 +-- pymatgen/electronic_structure/plotter.py | 10 ++--- pymatgen/io/abinit/abiobjects.py | 4 +- pymatgen/io/abinit/inputs.py | 6 +-- pymatgen/io/vasp/outputs.py | 12 +++--- 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/pymatgen/analysis/chemenv/connectivity/connected_components.py b/pymatgen/analysis/chemenv/connectivity/connected_components.py index 7bc4d392f89..4a5114b3821 100644 --- a/pymatgen/analysis/chemenv/connectivity/connected_components.py +++ b/pymatgen/analysis/chemenv/connectivity/connected_components.py @@ -574,32 +574,28 @@ def is_0d(self) -> bool: """Whether this connected component is 0-dimensional.""" if self._periodicity_vectors is None: self.compute_periodicity() - assert self._periodicity_vectors is not None # fix mypy arg 1 to len has incompatible type Optional - return len(self._periodicity_vectors) == 0 + return len(self._periodicity_vectors) == 0 # type: ignore[arg-type] @property def is_1d(self) -> bool: """Whether this connected component is 1-dimensional.""" if self._periodicity_vectors is None: self.compute_periodicity() - assert self._periodicity_vectors is not None # fix mypy arg 1 to len has incompatible type Optional - return len(self._periodicity_vectors) == 1 + return len(self._periodicity_vectors) == 1 # type: ignore[arg-type] @property def is_2d(self) -> bool: """Whether this connected component is 2-dimensional.""" if self._periodicity_vectors is None: self.compute_periodicity() - assert self._periodicity_vectors is not None # fix mypy arg 1 to len has incompatible type Optional - return len(self._periodicity_vectors) == 2 + return len(self._periodicity_vectors) == 2 # type: ignore[arg-type] @property def is_3d(self) -> bool: """Whether this connected component is 3-dimensional.""" if self._periodicity_vectors is None: self.compute_periodicity() - assert self._periodicity_vectors is not None # fix mypy arg 1 to len has incompatible type Optional - return len(self._periodicity_vectors) == 3 + return len(self._periodicity_vectors) == 3 # type: ignore[arg-type] @staticmethod def _order_vectors(vectors): @@ -654,10 +650,10 @@ def elastic_centered_graph(self, start_node=None): logging.info("In elastic centering") # Loop on start_nodes, sometimes some nodes cannot be elastically taken # inside the cell if you start from a specific node - ntest_nodes = 0 + n_test_nodes = 0 start_node = next(iter(self.graph.nodes())) - ntest_nodes += 1 + n_test_nodes += 1 centered_connected_subgraph = nx.MultiGraph() centered_connected_subgraph.add_nodes_from(self.graph.nodes()) centered_connected_subgraph.add_edges_from(self.graph.edges(data=True)) @@ -782,12 +778,21 @@ def _retuplify_edgedata(edata): """ Private method used to cast back lists to tuples where applicable in an edge data. - The format of the edge data is : - {'start': STARTINDEX, 'end': ENDINDEX, 'delta': TUPLE(DELTAX, DELTAY, DELTAZ), - 'ligands': [TUPLE(LIGAND_1_INDEX, TUPLE(DELTAX_START_LIG_1, DELTAY_START_LIG_1, DELTAZ_START_LIG_1), - TUPLE(DELTAX_END_LIG_1, DELTAY_END_LIG_1, DELTAZ_END_LIG_1)), - TUPLE(LIGAND_2_INDEX, ...), - ... ]} + The format of the edge data is: + { + "start": STARTINDEX, + "end": ENDINDEX, + "delta": TUPLE(DELTAX, DELTAY, DELTAZ), + "ligands": [ + TUPLE( + LIGAND_1_INDEX, + TUPLE(DELTAX_START_LIG_1, DELTAY_START_LIG_1, DELTAZ_START_LIG_1), + TUPLE(DELTAX_END_LIG_1, DELTAY_END_LIG_1, DELTAZ_END_LIG_1), + ), + TUPLE(LIGAND_2_INDEX, ...), + ..., + ], + } When serializing to json/bson, these tuples are transformed into lists. This method transforms these lists back to tuples. diff --git a/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py b/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py index 2db22268326..ae474188c67 100644 --- a/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py +++ b/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py @@ -1584,9 +1584,9 @@ def coordination_geometry_symmetry_measures_separation_plane_optim( Returns: tuple: Continuous symmetry measures for the given coordination geometry for each plane and permutation - investigated, corresponding permutations, corresponding algorithms, - corresponding mappings from local to perfect environment and corresponding mappings - from perfect to local environment. + investigated, corresponding permutations, corresponding algorithms, + corresponding mappings from local to perfect environment and corresponding mappings + from perfect to local environment. """ if optimization == 2: logging.log(level=5, msg="... using optimization = 2") diff --git a/pymatgen/electronic_structure/plotter.py b/pymatgen/electronic_structure/plotter.py index b4e5c3875c6..04010f49289 100644 --- a/pymatgen/electronic_structure/plotter.py +++ b/pymatgen/electronic_structure/plotter.py @@ -3298,7 +3298,7 @@ def plot_seebeck_dop(self, temps="all", output="average"): Args: temps: the default 'all' plots all the temperatures in the analyzer. - Specify a list of temperatures if you want to plot only some. + Specify a list of temperatures if you want to plot only some. output: with 'average' you get an average of the three directions with 'eigs' you get all the three directions. @@ -3343,7 +3343,7 @@ def plot_conductivity_dop(self, temps="all", output="average", relaxation_time=1 Args: temps: the default 'all' plots all the temperatures in the analyzer. - Specify a list of temperatures if you want to plot only some. + Specify a list of temperatures if you want to plot only some. output: with 'average' you get an average of the three directions with 'eigs' you get all the three directions. relaxation_time: specify a constant relaxation time value @@ -3392,7 +3392,7 @@ def plot_power_factor_dop(self, temps="all", output="average", relaxation_time=1 Args: temps: the default 'all' plots all the temperatures in the analyzer. - Specify a list of temperatures if you want to plot only some. + Specify a list of temperatures if you want to plot only some. output: with 'average' you get an average of the three directions with 'eigs' you get all the three directions. relaxation_time: specify a constant relaxation time value @@ -3438,7 +3438,7 @@ def plot_zt_dop(self, temps="all", output="average", relaxation_time=1e-14): Args: temps: the default 'all' plots all the temperatures in the analyzer. - Specify a list of temperatures if you want to plot only some. + Specify a list of temperatures if you want to plot only some. output: with 'average' you get an average of the three directions with 'eigs' you get all the three directions. relaxation_time: specify a constant relaxation time value @@ -3489,7 +3489,7 @@ def plot_eff_mass_dop(self, temps="all", output="average"): Args: temps: the default 'all' plots all the temperatures in the analyzer. - Specify a list of temperatures if you want to plot only some. + Specify a list of temperatures if you want to plot only some. output: with 'average' you get an average of the three directions with 'eigs' you get all the three directions. relaxation_time: specify a constant relaxation time value diff --git a/pymatgen/io/abinit/abiobjects.py b/pymatgen/io/abinit/abiobjects.py index 9ec268e92d4..23b2cc53b28 100644 --- a/pymatgen/io/abinit/abiobjects.py +++ b/pymatgen/io/abinit/abiobjects.py @@ -105,9 +105,7 @@ def structure_from_abivars(cls=None, *args, **kwargs): Example: al_structure = structure_from_abivars( acell=3*[7.5], - rprim=[0.0, 0.5, 0.5, - 0.5, 0.0, 0.5, - 0.5, 0.5, 0.0], + rprim=[0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0], typat=1, xred=[0.0, 0.0, 0.0], ntypat=1, diff --git a/pymatgen/io/abinit/inputs.py b/pymatgen/io/abinit/inputs.py index 385fb0010f0..a4192d46e19 100644 --- a/pymatgen/io/abinit/inputs.py +++ b/pymatgen/io/abinit/inputs.py @@ -247,7 +247,7 @@ def _get_shifts(shift_mode, structure): return shifts return ((0, 0, 0),) - raise ValueError(f"invalid {shift_mode=}") + raise ValueError(f"Invalid {shift_mode=}") def gs_input( @@ -272,9 +272,9 @@ def gs_input( kppa: Defines the sampling used for the SCF run. Defaults to 1000 if not given. ecut: cutoff energy in Ha (if None, ecut is initialized from the pseudos according to accuracy) pawecutdg: cutoff energy in Ha for PAW double-grid (if None, pawecutdg is initialized from the pseudos - according to accuracy) + according to accuracy) scf_nband: Number of bands for SCF run. If scf_nband is None, nband is automatically initialized - from the list of pseudos, the structure and the smearing option. + from the list of pseudos, the structure and the smearing option. accuracy: Accuracy of the calculation. spin_mode: Spin polarization. smearing: Smearing technique. diff --git a/pymatgen/io/vasp/outputs.py b/pymatgen/io/vasp/outputs.py index 1f5506d78ef..2f3bbc2fee3 100644 --- a/pymatgen/io/vasp/outputs.py +++ b/pymatgen/io/vasp/outputs.py @@ -4138,12 +4138,12 @@ def get_adjusted_fermi_level(efermi, cbm, band_structure): # make a working copy of band_structure bs_working = BandStructureSymmLine.from_dict(band_structure.as_dict()) if bs_working.is_metal(): - e = efermi - while e < cbm: - e += 0.01 - bs_working._efermi = e + energy = efermi + while energy < cbm: + energy += 0.01 + bs_working._efermi = energy if not bs_working.is_metal(): - return e + return energy return efermi @@ -4249,7 +4249,7 @@ def __init__(self, filename="WAVECAR", verbose=False, precision="normal", vasp_t # and occupations in way that does not span FORTRAN records, but # reader below appears to assume that record boundaries can be ignored # (see OUTWAV vs. OUTWAV_4 in vasp fileio.F) - raise ValueError(f"invalid {rtag=}, must be one of {valid_rtags}") + raise ValueError(f"Invalid {rtag=}, must be one of {valid_rtags}") # padding to end of fortran REC=1 np.fromfile(f, dtype=np.float64, count=recl8 - 3)