Skip to content

Commit f9e2830

Browse files
committed
rename single-letter variables f->file
1 parent 59a76b5 commit f9e2830

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+518
-516
lines changed

pymatgen/alchemy/materials.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ def write_vasp_input(
206206
**kwargs: All keyword args supported by the VASP input set.
207207
"""
208208
vasp_input_set(self.final_structure, **kwargs).write_input(output_dir, make_dir_if_not_present=create_directory)
209-
with open(f"{output_dir}/transformations.json", mode="w") as fp:
210-
json.dump(self.as_dict(), fp)
209+
with open(f"{output_dir}/transformations.json", mode="w") as file:
210+
json.dump(self.as_dict(), file)
211211

212212
def __str__(self) -> str:
213213
output = ["Current structure", "------------", str(self.final_structure), "\nHistory", "------------"]

pymatgen/alchemy/transmuters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ def from_filenames(cls, filenames, transformations=None, primitive=True, extend_
268268
extend_collection: Same meaning as in __init__.
269269
"""
270270
cif_files = []
271-
for fname in filenames:
272-
with open(fname) as file:
271+
for filename in filenames:
272+
with open(filename) as file:
273273
cif_files.append(file.read())
274274
return cls(
275275
"\n".join(cif_files),

pymatgen/analysis/chemenv/utils/chemenv_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def auto_load(cls, root_dir=None):
165165
root_dir = f"{home}/.chemenv"
166166
config_file = f"{root_dir}/config.json"
167167
try:
168-
with open(config_file) as f:
169-
config_dict = json.load(f)
168+
with open(config_file) as file:
169+
config_dict = json.load(file)
170170
return ChemEnvConfig(package_options=config_dict["package_options"])
171171

172172
except OSError:

pymatgen/analysis/hhi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def __init__(self):
3737
"""Init for HHIModel."""
3838
self.symbol_hhip_hhir = {} # symbol->(HHI_production, HHI reserve)
3939

40-
with open(csv_path) as f:
41-
for line in f:
40+
with open(csv_path) as file:
41+
for line in file:
4242
if line[0] != "#":
4343
symbol, hhi_production, hhi_reserve = line.split(",")
4444
self.symbol_hhip_hhir[symbol] = float(hhi_production), float(hhi_reserve)

pymatgen/analysis/structure_prediction/substitution_probability.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def __init__(self, lambda_table=None, alpha=-5):
5858
else:
5959
module_dir = os.path.dirname(__file__)
6060
json_file = f"{module_dir}/data/lambda.json"
61-
with open(json_file) as f:
62-
self._lambda_table = json.load(f)
61+
with open(json_file) as file:
62+
self._lambda_table = json.load(file)
6363

6464
# build map of specie pairs to lambdas
6565
self.alpha = alpha

pymatgen/cli/pmg_potcar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def gen_potcar(dirname, filename):
3333
"""
3434
if filename == "POTCAR.spec":
3535
fullpath = os.path.join(dirname, filename)
36-
with open(fullpath) as f:
37-
elements = f.readlines()
36+
with open(fullpath) as file:
37+
elements = file.readlines()
3838
symbols = [el.strip() for el in elements if el.strip() != ""]
3939
potcar = Potcar(symbols)
4040
potcar.write_file(f"{dirname}/POTCAR")

pymatgen/command_line/enumlib_caller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ def _get_structures(self, num_structs):
353353
inv_org_latt = None
354354

355355
for file in glob("vasp.*"):
356-
with open(file) as f:
357-
data = f.read()
356+
with open(file) as file:
357+
data = file.read()
358358
data = re.sub(r"scale factor", "1", data)
359359
data = re.sub(r"(\d+)-(\d+)", r"\1 -\2", data)
360360
poscar = Poscar.from_str(data, self.index_species)

pymatgen/command_line/mcsqs_caller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ def _parse_clusters(filename):
234234
num_possible_species: int
235235
cluster_function: float
236236
"""
237-
with open(filename) as f:
238-
lines = f.readlines()
237+
with open(filename) as file:
238+
lines = file.readlines()
239239

240240
clusters = []
241241
cluster_block = []

pymatgen/command_line/vampire_caller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ def _create_input(self):
296296

297297
input_script = "\n".join(input_script)
298298

299-
with open("input", mode="w") as f:
300-
f.write(input_script)
299+
with open("input", mode="w") as file:
300+
file.write(input_script)
301301

302302
def _create_ucf(self):
303303
structure = self.structure

pymatgen/core/structure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,8 +2887,8 @@ def from_file( # type: ignore[override]
28872887
from pymatgen.io.vasp import Chgcar, Vasprun
28882888

28892889
fname = os.path.basename(filename)
2890-
with zopen(filename, mode="rt", errors="replace") as f:
2891-
contents = f.read()
2890+
with zopen(filename, mode="rt", errors="replace") as file:
2891+
contents = file.read()
28922892
if fnmatch(fname.lower(), "*.cif*") or fnmatch(fname.lower(), "*.mcif*"):
28932893
return cls.from_str(contents, fmt="cif", primitive=primitive, sort=sort, merge_tol=merge_tol, **kwargs)
28942894
if fnmatch(fname, "*POSCAR*") or fnmatch(fname, "*CONTCAR*") or fnmatch(fname, "*.vasp"):

0 commit comments

Comments
 (0)