Skip to content

Commit

Permalink
Fix linting errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Aug 31, 2021
1 parent b4c3f62 commit f978687
Show file tree
Hide file tree
Showing 39 changed files with 159 additions and 159 deletions.
2 changes: 1 addition & 1 deletion pymatgen/alchemy/tests/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_append_transformation(self):
self.trans.append_transformation(t)
self.assertEqual("NaMnPO4", self.trans.final_structure.composition.reduced_formula)
self.assertEqual(len(self.trans.structures), 3)
coords = list()
coords = []
coords.append([0, 0, 0])
coords.append([0.75, 0.5, 0.75])
lattice = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ def __init__(self, permutations_safe_override=False, only_symbols=None):
only_symbols: Whether to restrict the list of environments to be identified.
"""
dict.__init__(self)
self.cg_list = list()
self.cg_list = []
if only_symbols is None:
with open("{}/coordination_geometries_files/allcg.txt".format(module_dir), "r") as f:
data = f.readlines()
Expand Down Expand Up @@ -1075,7 +1075,7 @@ def get_geometries(self, coordination=None, returned="cg"):
coordination: The coordination number of which the list of coordination geometries are returned.
returned: Type of objects in the list.
"""
geom = list()
geom = []
if coordination is None:
for gg in self.cg_list:
if returned == "cg":
Expand Down Expand Up @@ -1139,7 +1139,7 @@ def get_implemented_geometries(self, coordination=None, returned="cg", include_d
returned: Type of objects in the list.
include_deactivated: Whether to include CoordinationGeometry that are deactivated.
"""
geom = list()
geom = []
if coordination is None:
for gg in self.cg_list:
if gg.points is not None and ((not gg.deactivate) or include_deactivated):
Expand Down Expand Up @@ -1169,7 +1169,7 @@ def get_not_implemented_geometries(self, coordination=None, returned="mp_symbol"
are returned.
returned: Type of objects in the list.
"""
geom = list()
geom = []
if coordination is None:
for gg in self.cg_list:
if gg.points is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ def setup_random_structure(self, coordination):
"""
aa = 0.4
bb = -0.2
coords = list()
coords = []
for ii in range(coordination + 1):
coords.append(
aa
Expand Down Expand Up @@ -1419,10 +1419,10 @@ def coordination_geometry_symmetry_measures_standard(
# np.float_)
if optimization == 2:
permutations_symmetry_measures = [None] * len(algo.permutations)
permutations = list()
algos = list()
local2perfect_maps = list()
perfect2local_maps = list()
permutations = []
algos = []
local2perfect_maps = []
perfect2local_maps = []
for iperm, perm in enumerate(algo.permutations):

local2perfect_map = {}
Expand Down Expand Up @@ -1450,10 +1450,10 @@ def coordination_geometry_symmetry_measures_standard(
)

permutations_symmetry_measures = [None] * len(algo.permutations)
permutations = list()
algos = list()
local2perfect_maps = list()
perfect2local_maps = list()
permutations = []
algos = []
local2perfect_maps = []
perfect2local_maps = []
for iperm, perm in enumerate(algo.permutations):
local2perfect_map = {}
perfect2local_map = {}
Expand Down Expand Up @@ -1493,14 +1493,14 @@ def coordination_geometry_symmetry_measures_separation_plane(
:param coordination_geometry: The coordination geometry to be investigated
:return: The symmetry measures for the given coordination geometry for each plane and permutation investigated
"""
permutations = list()
permutations_symmetry_measures = list()
plane_separations = list()
algos = list()
perfect2local_maps = list()
local2perfect_maps = list()
permutations = []
permutations_symmetry_measures = []
plane_separations = []
algos = []
perfect2local_maps = []
local2perfect_maps = []
if testing:
separation_permutations = list()
separation_permutations = []
nplanes = 0
for npoints in range(
separation_plane_algo.minimum_number_of_points,
Expand Down Expand Up @@ -1613,11 +1613,11 @@ def coordination_geometry_symmetry_measures_separation_plane_optim(
raise ValueError("Optimization should be 1 or 2")
cn = len(self.local_geometry.coords)

permutations = list()
permutations_symmetry_measures = list()
algos = list()
perfect2local_maps = list()
local2perfect_maps = list()
permutations = []
permutations_symmetry_measures = []
algos = []
perfect2local_maps = []
local2perfect_maps = []

if separation_plane_algo.separation in nb_set.separations:
for sep_indices, (local_plane, npsep) in nb_set.separations[separation_plane_algo.separation].items():
Expand Down Expand Up @@ -2016,10 +2016,10 @@ def coordination_geometry_symmetry_measures_fallback_random(
:return: The symmetry measures for the given coordination geometry for each permutation investigated
"""
permutations_symmetry_measures = [None] * NRANDOM
permutations = list()
algos = list()
perfect2local_maps = list()
local2perfect_maps = list()
permutations = []
algos = []
perfect2local_maps = []
local2perfect_maps = []
for iperm in range(NRANDOM):
perm = np.random.permutation(coordination_geometry.coordination_number)
permutations.append(perm)
Expand Down
14 changes: 7 additions & 7 deletions pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def rotateCoords(coords, R):
:param R: Rotation matrix
:return: List of rotated points
"""
newlist = list()
newlist = []
for pp in coords:
rpp = matrixTimesVector(R, pp)
newlist.append(rpp)
Expand Down Expand Up @@ -466,7 +466,7 @@ def changebasis(uu, vv, nn, pps):
MM[ii, 1] = vv[ii]
MM[ii, 2] = nn[ii]
PP = np.linalg.inv(MM)
newpps = list()
newpps = []
for pp in pps:
newpps.append(matrixTimesVector(PP, pp))
return newpps
Expand Down Expand Up @@ -501,7 +501,7 @@ def anticlockwise_sort(pps):
:param pps: List of points to be sorted
:return: Sorted list of points
"""
newpps = list()
newpps = []
angles = np.zeros(len(pps), np.float_)
for ipp, pp in enumerate(pps):
angles[ipp] = np.arctan2(pp[1], pp[0])
Expand Down Expand Up @@ -724,9 +724,9 @@ def indices_separate(self, points, dist_tolerance):
:return: The lists of indices of the points on one side of the plane, on the plane and
on the other side of the plane
"""
side1 = list()
inplane = list()
side2 = list()
side1 = []
inplane = []
side2 = []
for ip, pp in enumerate(points):
if self.is_in_plane(pp, dist_tolerance):
inplane.append(ip)
Expand Down Expand Up @@ -862,7 +862,7 @@ def project_and_to2dim(self, pps, plane_center):
proj = self.projectionpoints(pps)
[u1, u2, u3] = self.orthonormal_vectors()
PP = np.array([[u1[0], u2[0], u3[0]], [u1[1], u2[1], u3[1]], [u1[2], u2[2], u3[2]]])
xypps = list()
xypps = []
for pp in proj:
xyzpp = np.dot(pp, PP)
xypps.append(xyzpp[0:2])
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/analysis/chemenv/utils/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def get_all_elementary_cycles(graph):
cycles_matrix[icycle, iedge] = True

# print(cycles_matrix)
elementary_cycles_list = list()
elementary_cycles_list = []

for ncycles in range(1, len(cycle_basis) + 1):
for cycles_combination in itertools.combinations(cycles_matrix, ncycles):
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/analysis/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ def get_disconnected_fragments(self):
return [copy.deepcopy(self)]

original = copy.deepcopy(self)
sub_mols = list()
sub_mols = []

# Had to use nx.weakly_connected_components because of deprecation
# of nx.weakly_connected_component_subgraphs
Expand Down Expand Up @@ -2443,7 +2443,7 @@ def replace_group(
)

to_remove = set()
sizes = dict()
sizes = {}
disconnected = self.graph.to_undirected()
disconnected.remove_node(index)
for neighbor in neighbors:
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/analysis/local_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def _get_nn_shell_info(
# Each allowed step results in many terminal neighbors
# And, different first steps might results in the same neighbor
# Now, we condense those neighbors into a single entry per neighbor
all_sites = dict()
all_sites = {}
for first_site, term_sites in zip(allowed_steps, terminal_neighbors):
for term_site in term_sites:
key = (term_site["site_index"], tuple(term_site["image"]))
Expand Down
8 changes: 4 additions & 4 deletions pymatgen/analysis/phase_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ def pd_plot_data(self):

all_entries = pd.all_entries
all_data = np.array(pd.all_entries_hulldata)
unstable_entries = dict()
unstable_entries = {}
stable = pd.stable_entries
for i, entry in enumerate(all_entries):
if entry not in stable:
Expand Down Expand Up @@ -2071,7 +2071,7 @@ def _get_3d_plot(self, label_stable=True):
font = FontProperties(weight="bold", size=13)
(lines, labels, unstable) = self.pd_plot_data
count = 1
newlabels = list()
newlabels = []
for x, y, z in lines:
ax.plot(
x,
Expand Down Expand Up @@ -2472,7 +2472,7 @@ def _create_plotly_figure_layout(self, label_stable=True):
:return: Dictionary with Plotly figure layout settings.
"""
annotations_list = None
layout = dict()
layout = {}

if label_stable:
annotations_list = self._create_plotly_element_annotations()
Expand Down Expand Up @@ -2563,7 +2563,7 @@ def get_marker_props(coords, entries, stable=True):

unstable_props = get_marker_props(unstable_coords, unstable_entries, stable=False)

stable_markers, unstable_markers = dict(), dict()
stable_markers, unstable_markers = {}, {}

if self._dim == 2:
stable_markers = plotly_layouts["default_binary_marker_settings"].copy()
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/analysis/pourbaix_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def _preprocess_pourbaix_entries(self, entries, nproc=None):
combos = []
for facet in valid_facets:
for i in range(1, self.dim + 2):
these_combos = list()
these_combos = []
for combo in itertools.combinations(facet, i):
these_entries = [min_entries[i] for i in combo]
these_combos.append(frozenset(these_entries))
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/analysis/tests/test_structure_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_oxide_type(self):
el_o = Element("O")
latt = Lattice([[3.985034, 0.0, 0.0], [0.0, 4.881506, 0.0], [0.0, 0.0, 2.959824]])
elts = [el_li, el_li, el_o, el_o, el_o, el_o]
coords = list()
coords = []
coords.append([0.500000, 0.500000, 0.500000])
coords.append([0.0, 0.0, 0.0])
coords.append([0.632568, 0.085090, 0.500000])
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/command_line/gulp_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ def __init__(self):
"""
module_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(module_dir, "OxideTersoffPotentials"), "r") as f:
data = dict()
data = {}
for row in f:
metaloxi = row.split()[0]
line = row.split(")")
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/core/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self, *args, strict: bool = False, **kwargs):
dict(). Also extended to allow simple string init.
Args:
Any form supported by the Python built-in dict() function.
Any form supported by the Python built-in {} function.
1. A dict of either {Element/Species: amount},
Expand All @@ -119,7 +119,7 @@ def __init__(self, *args, strict: bool = False, **kwargs):
"""
self.allow_negative = kwargs.pop("allow_negative", False)
# it's much faster to recognize a composition and use the elmap than
# to pass the composition to dict()
# to pass the composition to {}
if len(args) == 1 and isinstance(args[0], Composition):
elmap = args[0]
elif len(args) == 1 and isinstance(args[0], str):
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/core/tests/test_ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class IonTest(unittest.TestCase):
def setUp(self):
self.comp = list()
self.comp = []
self.comp.append(Ion.from_formula("Li+"))
self.comp.append(Ion.from_formula("MnO4-"))
self.comp.append(Ion.from_formula("Mn++"))
Expand Down

0 comments on commit f978687

Please sign in to comment.