Skip to content

Commit

Permalink
reformat long unpackings
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Aug 18, 2023
1 parent eb9cc3e commit 572f67c
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,12 @@ def get_pmeshes(self, sites, permutation=None):
# _vertices = [site.coords for site in sites]
_vertices = [site.coords for site in sites] if permutation is None else [sites[ii].coords for ii in permutation]
_face_centers = []
number_of_faces = 0
n_faces = 0
for face in self._faces:
if len(face) in [3, 4]:
number_of_faces += 1
n_faces += 1
else:
number_of_faces += len(face)
n_faces += len(face)

_face_centers.append(
np.array([np.mean([_vertices[face_vertex][ii] for face_vertex in face]) for ii in range(3)])
Expand All @@ -866,7 +866,7 @@ def get_pmeshes(self, sites, permutation=None):
out += f"{vv[0]:15.8f} {vv[1]:15.8f} {vv[2]:15.8f}\n"
for fc in _face_centers:
out += f"{fc[0]:15.8f} {fc[1]:15.8f} {fc[2]:15.8f}\n"
out += f"{number_of_faces}\n"
out += f"{n_faces}\n"
for iface, face in enumerate(self._faces):
if len(face) == 3:
out += "4\n"
Expand Down
5 changes: 1 addition & 4 deletions pymatgen/analysis/chempot_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ def __init__(
self._min_entries, self._el_refs = self._get_min_entries_and_el_refs(self.entries)
self._entry_dict = {e.composition.reduced_formula: e for e in self._min_entries}
self._border_hyperplanes = self._get_border_hyperplanes()
(
self._hyperplanes,
self._hyperplane_entries,
) = self._get_hyperplanes_and_entries()
self._hyperplanes, self._hyperplane_entries = self._get_hyperplanes_and_entries()

if self.dim < 2:
raise ValueError("ChemicalPotentialDiagram currently requires phase diagrams with 2 or more elements!")
Expand Down
8 changes: 4 additions & 4 deletions pymatgen/analysis/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,8 @@ def get_coordination_of_site(self, n):
:param n: index of site
:return (int):
"""
number_of_self_loops = sum(1 for n, v in self.graph.edges(n) if n == v)
return self.graph.degree(n) - number_of_self_loops
n_self_loops = sum(1 for n, v in self.graph.edges(n) if n == v)
return self.graph.degree(n) - n_self_loops

def draw_graph_to_file(
self,
Expand Down Expand Up @@ -2440,8 +2440,8 @@ def get_coordination_of_site(self, n):
:param n: index of site
:return (int):
"""
number_of_self_loops = sum(1 for n, v in self.graph.edges(n) if n == v)
return self.graph.degree(n) - number_of_self_loops
n_self_loops = sum(1 for n, v in self.graph.edges(n) if n == v)
return self.graph.degree(n) - n_self_loops

def draw_graph_to_file(
self,
Expand Down
18 changes: 4 additions & 14 deletions pymatgen/analysis/wulff.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,7 @@ def get_plot(
from mpl_toolkits.mplot3d import Axes3D, art3d

colors = self._get_colors(color_set, alpha, off_color, custom_colors=custom_colors or {})
(
color_list,
color_proxy,
color_proxy_on_wulff,
miller_on_wulff,
e_surf_on_wulff,
) = colors
color_list, color_proxy, color_proxy_on_wulff, miller_on_wulff, e_surf_on_wulff = colors

if not direction:
# If direction is not specified, use the miller indices of
Expand Down Expand Up @@ -539,13 +533,9 @@ def get_plotly(
(plotly.graph_objs.Figure)
"""
units = "Jm⁻²" if units_in_JPERM2 else "eVÅ⁻²"
(
color_list,
color_proxy,
color_proxy_on_wulff,
miller_on_wulff,
e_surf_on_wulff,
) = self._get_colors(color_set, alpha, off_color, custom_colors=custom_colors or {})
color_list, color_proxy, color_proxy_on_wulff, miller_on_wulff, e_surf_on_wulff = self._get_colors(
color_set, alpha, off_color, custom_colors=custom_colors or {}
)

planes_data, color_scale, ticktext, tickvals = [], [], [], []
for plane in self.facets:
Expand Down
5 changes: 1 addition & 4 deletions pymatgen/apps/battery/insertion_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,7 @@ def from_entries(cls, entry1, entry2, working_ion_entry):
valence_list = Element(ion_sym).oxidation_states
working_ion_valence = abs(max(valence_list))

(
framework,
norm_charge,
) = frame_charge_comp.get_reduced_composition_and_factor()
framework, norm_charge = frame_charge_comp.get_reduced_composition_and_factor()
norm_discharge = frame_discharge_comp.get_reduced_composition_and_factor()[1]

# Initialize normalized properties
Expand Down
8 changes: 1 addition & 7 deletions pymatgen/electronic_structure/boltztrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1931,13 +1931,7 @@ def from_files(path_dir, dos_spin=1):
Returns:
a BoltztrapAnalyzer object
"""
(
run_type,
warning,
efermi,
gap,
doping_levels,
) = BoltztrapAnalyzer.parse_outputtrans(path_dir)
run_type, warning, efermi, gap, doping_levels = BoltztrapAnalyzer.parse_outputtrans(path_dir)

vol = BoltztrapAnalyzer.parse_struct(path_dir)

Expand Down
16 changes: 4 additions & 12 deletions pymatgen/electronic_structure/boltztrap2.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,12 +719,9 @@ def __init__(
)

# Compute the Onsager coefficients from those Fermi integrals
(
self.Conductivity_mu,
self.Seebeck_mu,
self.Kappa_mu,
Hall_mu,
) = BL.calc_Onsager_coefficients(L0, L1, L2, self.mu_r, temp_r, self.volume, Lm11=Lm11)
self.Conductivity_mu, self.Seebeck_mu, self.Kappa_mu, Hall_mu = BL.calc_Onsager_coefficients(
L0, L1, L2, self.mu_r, temp_r, self.volume, Lm11=Lm11
)

# Common properties rescaling
self.Conductivity_mu *= CRTA # S / m
Expand Down Expand Up @@ -785,12 +782,7 @@ def compute_properties_doping(self, doping, temp_r=None):
if temp_r is None:
temp_r = self.temp_r

(
self.Conductivity_doping,
self.Seebeck_doping,
self.Kappa_doping,
self.Carriers_conc_doping,
) = ({}, {}, {}, {})
self.Conductivity_doping, self.Seebeck_doping, self.Kappa_doping, self.Carriers_conc_doping = {}, {}, {}, {}

self.Power_Factor_doping, self.Effective_mass_doping = {}, {}

Expand Down
22 changes: 6 additions & 16 deletions pymatgen/io/lobster/lobsterenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,9 @@ def get_info_cohps_to_neighbors(
as given by isites and the other parameters
"""
# TODO: add options for orbital-resolved cohps
(
summed_icohps,
list_icohps,
number_bonds,
labels,
atoms,
final_isites,
) = self.get_info_icohps_to_neighbors(isites=isites, onlycation_isites=onlycation_isites)
summed_icohps, list_icohps, number_bonds, labels, atoms, final_isites = self.get_info_icohps_to_neighbors(
isites=isites, onlycation_isites=onlycation_isites
)

import tempfile

Expand Down Expand Up @@ -720,14 +715,9 @@ def _evaluate_ce(
raise ValueError("Please give two limits or leave them both at None")

# find environments based on ICOHP values
(
list_icohps,
list_keys,
list_lengths,
list_neighisite,
list_neighsite,
list_coords,
) = self._find_environments(additional_condition, lowerlimit, upperlimit, only_bonds_to)
list_icohps, list_keys, list_lengths, list_neighisite, list_neighsite, list_coords = self._find_environments(
additional_condition, lowerlimit, upperlimit, only_bonds_to
)

self.list_icohps = list_icohps
self.list_lengths = list_lengths
Expand Down
15 changes: 2 additions & 13 deletions pymatgen/io/lobster/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,7 @@ def __init__(self, filename="lobsterout"):
self.charge_spilling = chargespilling
self.total_spilling = totalspilling

(
elements,
basistype,
basisfunctions,
) = self._get_elements_basistype_basisfunctions(data=data)
elements, basistype, basisfunctions = self._get_elements_basistype_basisfunctions(data=data)
self.elements = elements
self.basis_type = basistype
self.basis_functions = basisfunctions
Expand Down Expand Up @@ -1440,14 +1436,7 @@ def __init__(self, filename, structure):
"""
self.filename = filename
self.structure = structure

(
self.grid,
self.points,
self.real,
self.imaginary,
self.distance,
) = Wavefunction._parse_file(filename)
self.grid, self.points, self.real, self.imaginary, self.distance = Wavefunction._parse_file(filename)

@staticmethod
def _parse_file(filename):
Expand Down
5 changes: 1 addition & 4 deletions pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1573,10 +1573,7 @@ def __init__(
elif tag == "eigenvalues":
self.eigenvalues = self._parse_eigen(elem)
elif parse_projected_eigen and tag == "projected":
(
self.projected_eigenvalues,
self.projected_magnetisation,
) = self._parse_projected_eigen(elem)
self.projected_eigenvalues, self.projected_magnetisation = self._parse_projected_eigen(elem)
elif tag == "structure" and elem.attrib.get("name") == "finalpos":
self.final_structure = self._parse_structure(elem)
self.vasp_version = self.generator["version"]
Expand Down

0 comments on commit 572f67c

Please sign in to comment.