Skip to content

Commit 0e4547f

Browse files
authored
Merge pull request #755 from janosh/from-monty-to-shutil-which
From `monty` to `shutil` `which`
2 parents 5b84933 + a3efc15 commit 0e4547f

File tree

10 files changed

+118
-109
lines changed

10 files changed

+118
-109
lines changed

atomate/common/firetasks/glue_tasks.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ class CopyFilesFromCalcLoc(FiretaskBase):
9999
"""
100100

101101
required_params = ["calc_loc"]
102-
optional_params = ["filenames", "name_prepend",
103-
"name_append", "exclude_files",
104-
"decompress"]
102+
optional_params = [
103+
"filenames",
104+
"name_prepend",
105+
"name_append",
106+
"exclude_files",
107+
"decompress",
108+
]
105109

106110
def run_task(self, fw_spec=None):
107111
calc_loc = get_calc_loc(self["calc_loc"], fw_spec["calc_locs"])
@@ -146,13 +150,16 @@ def run_task(self, fw_spec=None):
146150
for f in files_to_copy:
147151
prev_path_full = os.path.join(calc_dir, f)
148152
f, ext = os.path.splitext(f)
149-
dest_fname = self.get("name_prepend", "") + f + self.get("name_append", "") + ext
153+
dest_fname = (
154+
self.get("name_prepend", "") + f + self.get("name_append", "") + ext
155+
)
150156
dest_path = os.path.join(os.getcwd(), dest_fname)
151157

152158
fileclient.copy(prev_path_full, dest_path)
153-
if self.get("decompress",False):
159+
if self.get("decompress", False):
154160
monty.shutil.decompress_file(dest_path)
155161

162+
156163
@explicit_serialize
157164
class DeleteFiles(FiretaskBase):
158165
"""

atomate/qchem/firetasks/tests/test_critic2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import os
33
import shutil
44
import unittest
5+
from shutil import which
56

6-
from monty.os.path import which
77
from pymatgen.io.qchem.outputs import QCOutput
88

99
from atomate.qchem.firetasks.critic2 import ProcessCritic2, RunCritic2

atomate/vasp/analysis/phonopy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,6 @@ def get_phonopy_thermal_expansion(
179179

180180
# thermal expansion coefficient and temperature
181181
max_t_index = phonopy_qha._qha._len
182-
alpha = phonopy_qha.get_thermal_expansion()[: max_t_index]
182+
alpha = phonopy_qha.get_thermal_expansion()[:max_t_index]
183183
T = phonopy_qha._qha._temperatures[:max_t_index]
184184
return alpha, T

atomate/vasp/drones.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
import traceback
1313
import warnings
1414
from fnmatch import fnmatch
15+
from shutil import which
1516

1617
import numpy as np
1718
from monty.io import zopen
1819
from monty.json import jsanitize
19-
from monty.os.path import which
2020
from pymatgen.apps.borg.hive import AbstractDrone
2121
from pymatgen.command_line.bader_caller import bader_analysis_from_path
2222
from pymatgen.core.composition import Composition
@@ -420,7 +420,7 @@ def generate_doc(self, dir_name, vasprun_files, outcar_files):
420420
d["output"][k] = d_calc_final["output"][k]
421421

422422
# store optical data, overwrites the LOPTICS data
423-
if d["input"]["incar"].get("ALGO") == 'CHI':
423+
if d["input"]["incar"].get("ALGO") == "CHI":
424424
for k in ["optical_absorption_coeff", "dielectric"]:
425425
d["output"][k] = d_calc_final["output"][k]
426426

@@ -588,7 +588,7 @@ def process_vasprun(self, dir_name, taskname, filename):
588588
d["output"]["optical_absorption_coeff"] = vrun.optical_absorption_coeff
589589

590590
# parse output from response function
591-
if vrun.incar.get("ALGO") == 'CHI':
591+
if vrun.incar.get("ALGO") == "CHI":
592592
dielectric = vrun.dielectric
593593
d["output"]["dielectric"] = dict(
594594
energy=dielectric[0], real=dielectric[1], imag=dielectric[2]

atomate/vasp/firetasks/absorption_tasks.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
import os
2-
from importlib import import_module
3-
4-
import numpy as np
5-
6-
from monty.serialization import dumpfn
71
from fireworks import FiretaskBase, explicit_serialize
8-
from fireworks.utilities.dict_mods import apply_mod
9-
from pymatgen.core.structure import Structure
10-
from pymatgen.io.vasp import Incar, Poscar, Potcar, PotcarSingle, Kpoints
112
from pymatgen.io.vasp.sets import MPAbsorptionSet
12-
from pymatgen.io.vasp.outputs import Vasprun
13-
from atomate.utils.utils import env_chk, load_class
3+
144

155
@explicit_serialize
166
class WriteVaspAbsorptionFromPrev(FiretaskBase):
@@ -25,6 +15,7 @@ class WriteVaspAbsorptionFromPrev(FiretaskBase):
2515
"potcar_spec"
2616
2717
"""
18+
2819
optional_params = [
2920
"prev_calc_dir",
3021
"structure",
@@ -37,7 +28,7 @@ class WriteVaspAbsorptionFromPrev(FiretaskBase):
3728
"ncores",
3829
"nedos",
3930
"potcar_spec",
40-
"other_params"
31+
"other_params",
4132
]
4233

4334
def run_task(self, fw_spec):

atomate/vasp/firetasks/glue_tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,14 @@ def interpolate_poscar(self, fw_spec):
290290
# use CopyFilesFromCalcLoc to get files from previous locations.
291291
CopyFilesFromCalcLoc(
292292
calc_loc=self["start"],
293-
filenames=["CONTCAR","CONTCAR.gz"],
293+
filenames=["CONTCAR", "CONTCAR.gz"],
294294
name_prepend=interpolate_folder + os.sep,
295295
name_append="_0",
296296
decompress=True,
297297
).run_task(fw_spec=fw_spec)
298298
CopyFilesFromCalcLoc(
299299
calc_loc=self["end"],
300-
filenames=["CONTCAR","CONTCAR.gz"],
300+
filenames=["CONTCAR", "CONTCAR.gz"],
301301
name_prepend=interpolate_folder + os.sep,
302302
name_append="_1",
303303
decompress=True,

atomate/vasp/firetasks/tests/test_exchange.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22
import unittest
3+
from shutil import which
34

45
import pandas as pd
5-
from monty.os.path import which
66
from pymatgen.core import Structure
77

88
from atomate.utils.testing import AtomateTest

0 commit comments

Comments
 (0)