Skip to content
Browse files

Cleanup.

  • Loading branch information...
1 parent 263b5e9 commit d2392caec981164667ff2773568363119be59c93 @shyuep shyuep committed
View
1 pymatgen/command_line/bader_caller.py
@@ -25,7 +25,6 @@
import os
import subprocess
-import tempfile
import shutil
from pymatgen.io.vaspio.vasp_output import Chgcar
View
4 pymatgen/command_line/enumlib_caller.py
@@ -31,16 +31,12 @@
__email__ = "shyuep@gmail.com"
__date__ = "Jul 16, 2012"
-import os
import re
import math
-import tempfile
import subprocess
-import shutil
import logging
import numpy as np
-import warnings
from pymatgen.io.vaspio.vasp_input import Poscar
from pymatgen.core.sites import PeriodicSite
View
2 pymatgen/core/physical_constants.py
@@ -33,8 +33,6 @@
Avogardo's constant
"""
-import numpy as _np
-
__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2011, The Materials Project"
__version__ = "1.0"
View
1 pymatgen/electronic_structure/boltztrap.py
@@ -153,7 +153,6 @@ def _make_def_file(self, def_file_name):
"36,'boltztrap_band.gpl', 'unknown', 'formatted',0\n")
def _make_proj_files(self, file_name, def_file_name):
- from pymatgen.electronic_structure.core import Orbital
for o in Orbital.all_orbitals:
for site_nb in range(0, len(self._bs._structure.sites)):
if o in self._bs._projections[Spin.up][0][0]:
View
2 pymatgen/io/nwchemio.py
@@ -5,7 +5,6 @@
"""
from __future__ import division
-import itertools
__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2012, The Materials Project"
@@ -517,6 +516,7 @@ def _parse_job(self, output):
coords = []
errors = []
basis_set = {}
+ bset_header = []
parse_geom = False
parse_freq = False
parse_bset = False
View
1 pymatgen/io/vaspio_set.py
@@ -726,7 +726,6 @@ def from_previous_vasp_run(previous_vasp_dir, output_dir='.',
outcar = Outcar(os.path.join(previous_vasp_dir, "OUTCAR"))
previous_incar = vasp_run.incar
previous_kpoints = vasp_run.kpoints
- previous_final_structure = vasp_run.final_structure
except:
traceback.format_exc()
raise RuntimeError("Can't get valid results from previous run")
View
11 pymatgen/io/zeoio.py
@@ -21,7 +21,6 @@
from pymatgen.core.structure import Structure, Molecule
from pymatgen.core.lattice import Lattice
-from pymatgen.core.sites import PeriodicSite
from pymatgen.io.cssrio import Cssr
from pymatgen.io.xyzio import XYZ
from monty.io import zopen
@@ -46,9 +45,9 @@ class ZeoCssr(Cssr):
structure: A structure to create ZeoCssr object
"""
- #@requires(zeo_found,
- # "ZeoCssr requires Zeo++ cython extension to be installed. Please "
- # "contact developers of Zeo++ to obtain it.")
+ @requires(zeo_found,
+ "ZeoCssr requires Zeo++ cython extension to be installed. Please "
+ "contact developers of Zeo++ to obtain it.")
def __init__(self, structure):
super(ZeoCssr, self).__init__(structure)
@@ -280,10 +279,10 @@ def get_voronoi_nodes(structure, rad_dict=None, probe_rad=0.1):
shutil.rmtree(temp_dir)
#PMG-Zeo c<->a transformation for voronoi face centers
- rot_face_centers = [(center[1],center[2],center[0]) for center in
+ rot_face_centers = [(center[1],center[2],center[0]) for center in
voronoi_face_centers]
species = ["X"] * len(rot_face_centers)
- prop = [0.0] * len(rot_face_centers) # Vor radius not evaluated for fc
+ prop = [0.0] * len(rot_face_centers) # Vor radius not evaluated for fc
voronoi_facecenter_struct = Structure(
lattice, species, rot_face_centers, coords_are_cartesian=True,
to_unit_cell=True, site_properties={"voronoi_radius": prop})
View
79 pymatgen/phasediagram/plotter.py
@@ -132,8 +132,8 @@ def _get_2d_plot(self, label_stable=True, label_unstable=True,
(lines, labels, unstable) = self.pd_plot_data
else:
(_lines, _labels, _unstable) = self.pd_plot_data
- (lines, labels, unstable) = order_phase_diagram(_lines, _labels,
- _unstable, ordering)
+ (lines, labels, unstable) = order_phase_diagram(
+ _lines, _labels, _unstable, ordering)
if energy_colormap is None:
if process_attributes:
for x, y in lines:
@@ -158,7 +158,6 @@ def _get_2d_plot(self, label_stable=True, label_unstable=True,
else:
from matplotlib.colors import Normalize, LinearSegmentedColormap
from matplotlib.cm import ScalarMappable
- from pymatgen.phasediagram.pdanalyzer import PDAnalyzer
pda = PDAnalyzer(self._pd)
for x, y in lines:
plt.plot(x, y, "k-", linewidth=3, markeredgecolor="k")
@@ -251,7 +250,6 @@ def _get_2d_plot(self, label_stable=True, label_unstable=True,
fontproperties=font)
if self.show_unstable:
- from pymatgen.phasediagram.pdanalyzer import PDAnalyzer
font = FontProperties()
font.set_size(16)
pda = PDAnalyzer(self._pd)
@@ -292,8 +290,8 @@ def _get_2d_plot(self, label_stable=True, label_unstable=True,
ticks = cbar.ax.get_yticklabels()
cbar.ax.set_yticklabels(['${v}$'.format(
v=float(t.get_text().strip('$'))*1000.0) for t in ticks])
- F = plt.gcf()
- F.set_size_inches((8, 6))
+ f = plt.gcf()
+ f.set_size_inches((8, 6))
plt.subplots_adjust(left=0.09, right=0.98, top=0.98, bottom=0.07)
return plt
@@ -563,7 +561,7 @@ def order_phase_diagram(lines, stable_entries, unstable_entries, ordering):
"""
Orders the entries (their coordinates) in a phase diagram plot according
to the user specified ordering.
- Ordering should be given as ['Up','Left','Right'], where Up,
+ Ordering should be given as ['Up', 'Left', 'Right'], where Up,
Left and Right are the names of the entries in the upper, left and right
corners of the triangle respectively.
@@ -603,7 +601,8 @@ def order_phase_diagram(lines, stable_entries, unstable_entries, ordering):
if (not nameup in ordering) or (not nameright in ordering) or \
(not nameleft in ordering):
raise ValueError(
- 'Error in ordering_phase_diagram : \n"{up}", "{left}" and "{right}"'
+ 'Error in ordering_phase_diagram : \n"{up}", "{left}" and "{'
+ 'right}"'
' should be in ordering : {ord}'.format(up=nameup, left=nameleft,
right=nameright,
ord=ordering))
@@ -617,9 +616,10 @@ def order_phase_diagram(lines, stable_entries, unstable_entries, ordering):
else:
newlines = [[np.array(1.0 - x), y] for x, y in lines]
newstable_entries = {(1.0 - c[0], c[1]): entry
- for c, entry in stable_entries.iteritems()}
+ for c, entry in stable_entries.items()}
newunstable_entries = {entry: (1.0 - c[0], c[1])
- for entry, c in unstable_entries.iteritems()}
+ for entry, c in
+ unstable_entries.items()}
return newlines, newstable_entries, newunstable_entries
elif nameup == ordering[1]:
if nameleft == ordering[2]:
@@ -630,16 +630,18 @@ def order_phase_diagram(lines, stable_entries, unstable_entries, ordering):
newx = np.zeros_like(x)
newy = np.zeros_like(y)
for ii, xx in enumerate(x):
- newx[ii] = c120*(xx-cc[0])-s120*(y[ii]-cc[1])+cc[0]
- newy[ii] = s120*(xx-cc[0])+c120*(y[ii]-cc[1])+cc[1]
+ newx[ii] = c120 * (xx - cc[0]) - s120 * (y[ii] - cc[1]) + \
+ cc[0]
+ newy[ii] = s120 * (xx - cc[0]) + c120 * (y[ii] - cc[1]) + \
+ cc[1]
newlines.append([newx, newy])
newstable_entries = {
- (c120*(c[0]-cc[0])-s120*(c[1]-cc[1])+cc[0],
- s120*(c[0]-cc[0])+c120*(c[1]-cc[1])+cc[1]): entry
+ (c120 * (c[0] - cc[0]) - s120 * (c[1] - cc[1]) + cc[0],
+ s120 * (c[0] - cc[0]) + c120 * (c[1] - cc[1]) + cc[1]): entry
for c, entry in stable_entries.iteritems()}
newunstable_entries = {
- entry: (c120*(c[0]-cc[0])-s120*(c[1]-cc[1])+cc[0],
- s120*(c[0]-cc[0])+c120*(c[1] - cc[1])+cc[1])
+ entry: (c120 * (c[0] - cc[0]) - s120 * (c[1] - cc[1]) + cc[0],
+ s120 * (c[0] - cc[0]) + c120 * (c[1] - cc[1]) + cc[1])
for entry, c in unstable_entries.iteritems()}
return newlines, newstable_entries, newunstable_entries
else:
@@ -650,15 +652,16 @@ def order_phase_diagram(lines, stable_entries, unstable_entries, ordering):
newx = np.zeros_like(x)
newy = np.zeros_like(y)
for ii, xx in enumerate(x):
- newx[ii] = -c120*(xx-1.0)-s120*y[ii]+1.0
- newy[ii] = -s120*(xx-1.0)+c120*y[ii]
+ newx[ii] = -c120 * (xx - 1.0) - s120 * y[ii] + 1.0
+ newy[ii] = -s120 * (xx - 1.0) + c120 * y[ii]
newlines.append([newx, newy])
- newstable_entries = {(-c120*(c[0]-1.0)-s120*c[1]+1.0,
- -s120*(c[0]-1.0)+c120*c[1]): entry
+ newstable_entries = {(-c120 * (c[0] - 1.0) - s120 * c[1] + 1.0,
+ -s120 * (c[0] - 1.0) + c120 * c[1]): entry
for c, entry in stable_entries.iteritems()}
- newunstable_entries = {entry: (-c120*(c[0]-1.0)-s120*c[1]+1.0,
- -s120*(c[0]-1.0)+c120*c[1])
- for entry, c in unstable_entries.iteritems()}
+ newunstable_entries = {
+ entry: (-c120 * (c[0] - 1.0) - s120 * c[1] + 1.0,
+ -s120 * (c[0] - 1.0) + c120 * c[1])
+ for entry, c in unstable_entries.iteritems()}
return newlines, newstable_entries, newunstable_entries
elif nameup == ordering[2]:
if nameleft == ordering[0]:
@@ -669,16 +672,18 @@ def order_phase_diagram(lines, stable_entries, unstable_entries, ordering):
newx = np.zeros_like(x)
newy = np.zeros_like(y)
for ii, xx in enumerate(x):
- newx[ii] = c240*(xx-cc[0])-s240*(y[ii]-cc[1])+cc[0]
- newy[ii] = s240*(xx-cc[0])+c240*(y[ii]-cc[1])+cc[1]
+ newx[ii] = c240 * (xx - cc[0]) - s240 * (y[ii] - cc[1]) + \
+ cc[0]
+ newy[ii] = s240 * (xx - cc[0]) + c240 * (y[ii] - cc[1]) + \
+ cc[1]
newlines.append([newx, newy])
newstable_entries = {
- (c240*(c[0]-cc[0])-s240*(c[1]-cc[1])+cc[0],
- s240*(c[0]-cc[0])+c240*(c[1]-cc[1])+cc[1]): entry
+ (c240 * (c[0] - cc[0]) - s240 * (c[1] - cc[1]) + cc[0],
+ s240 * (c[0] - cc[0]) + c240 * (c[1] - cc[1]) + cc[1]): entry
for c, entry in stable_entries.iteritems()}
newunstable_entries = {
- entry: (c240*(c[0]-cc[0])-s240*(c[1]-cc[1])+cc[0],
- s240*(c[0]-cc[0])+c240*(c[1] - cc[1])+cc[1])
+ entry: (c240 * (c[0] - cc[0]) - s240 * (c[1] - cc[1]) + cc[0],
+ s240 * (c[0] - cc[0]) + c240 * (c[1] - cc[1]) + cc[1])
for entry, c in unstable_entries.iteritems()}
return newlines, newstable_entries, newunstable_entries
else:
@@ -689,13 +694,13 @@ def order_phase_diagram(lines, stable_entries, unstable_entries, ordering):
newx = np.zeros_like(x)
newy = np.zeros_like(y)
for ii, xx in enumerate(x):
- newx[ii] = -c240*xx-s240*y[ii]
- newy[ii] = -s240*xx+c240*y[ii]
+ newx[ii] = -c240 * xx - s240 * y[ii]
+ newy[ii] = -s240 * xx + c240 * y[ii]
newlines.append([newx, newy])
- newstable_entries = {(-c240*c[0]-s240*c[1],
- -s240*c[0]+c240*c[1]): entry
- for c, entry in stable_entries.iteritems()}
- newunstable_entries = {entry: (-c240*c[0]-s240*c[1],
- -s240*c[0]+c240*c[1])
- for entry, c in unstable_entries.iteritems()}
+ newstable_entries = {(-c240 * c[0] - s240 * c[1],
+ -s240 * c[0] + c240 * c[1]): entry
+ for c, entry in stable_entries.items()}
+ newunstable_entries = {entry: (-c240 * c[0] - s240 * c[1],
+ -s240 * c[0] + c240 * c[1])
+ for entry, c in unstable_entries.items()}
return newlines, newstable_entries, newunstable_entries
View
42 pymatgen/transformations/advanced_transformations.py
@@ -29,8 +29,7 @@
SubstitutionPredictor
from pymatgen.analysis.structure_matcher import StructureMatcher, \
SpinComparator
-from pymatgen.analysis.energy_models import SymmetryModel, \
- EwaldElectrostaticModel, NsitesModel
+from pymatgen.analysis.energy_models import SymmetryModel
from pymatgen.serializers.json_coders import PMGJSONDecoder
@@ -55,9 +54,9 @@ def apply_transformation(self, structure):
if removal_fraction < 0:
raise ValueError("addition of specie not yet supported by "
"ChargeBalanceTransformation")
- trans = SubstitutionTransformation({self._charge_balance_sp:
- {self._charge_balance_sp:
- 1 - removal_fraction}})
+ trans = SubstitutionTransformation(
+ {self._charge_balance_sp: {self._charge_balance_sp:
+ 1 - removal_fraction}})
return trans.apply_transformation(structure)
def __str__(self):
@@ -162,8 +161,8 @@ def __init__(self, sp_to_replace, r_fraction, substitution_dict,
}
The number is the charge used for each of the list of elements
(an element can be present in multiple lists)
- charge_balance_species: If specified, will balance the charge on the structure using
- that specie.
+ charge_balance_species: If specified, will balance the charge on
+ the structure using that specie.
"""
self._sp_to_replace = sp_to_replace
self._r_fraction = r_fraction
@@ -184,9 +183,9 @@ def apply_transformation(self, structure, return_ranked_list=False):
else:
sign = "-"
dummy_sp = "X{}{}".format(str(charge), sign)
- mapping[self._sp_to_replace] = {self._sp_to_replace:
- 1 - self._r_fraction,
- dummy_sp: self._r_fraction}
+ mapping[self._sp_to_replace] = {
+ self._sp_to_replace: 1 - self._r_fraction,
+ dummy_sp: self._r_fraction}
trans = SubstitutionTransformation(mapping)
dummy_structure = trans.apply_transformation(structure)
if self._charge_balance_species is not None:
@@ -201,9 +200,9 @@ def apply_transformation(self, structure, return_ranked_list=False):
sign = "+"
else:
sign = "-"
- st = SubstitutionTransformation({"X{}+".format(str(charge)):
- "{}{}{}".format(el, charge,
- sign)})
+ st = SubstitutionTransformation(
+ {"X{}+".format(str(charge)): "{}{}{}".format(el, charge,
+ sign)})
new_structure = st.apply_transformation(dummy_structure)
outputs.append({"structure": new_structure})
return outputs
@@ -226,11 +225,11 @@ def is_one_to_many(self):
@property
def to_dict(self):
return {"name": self.__class__.__name__, "version": __version__,
- "init_args": {"sp_to_replace": self._sp_to_replace,
- "r_fraction": self._r_fraction,
- "substitution_dict": self._substitution_dict,
- "charge_balance_species":
- self._charge_balance_species},
+ "init_args": {
+ "sp_to_replace": self._sp_to_replace,
+ "r_fraction": self._r_fraction,
+ "substitution_dict": self._substitution_dict,
+ "charge_balance_species": self._charge_balance_species},
"@module": self.__class__.__module__,
"@class": self.__class__.__name__}
@@ -305,7 +304,7 @@ def apply_transformation(self, structure, return_ranked_list=False):
contains_oxidation_state = False
for sp in structure.composition.elements:
- if hasattr(sp, "oxi_state") and sp._oxi_state != 0:
+ if hasattr(sp, "oxi_state") and sp.oxi_state != 0:
contains_oxidation_state = True
break
@@ -485,8 +484,9 @@ def lcm(n1, n2):
n_gcd = reduce(gcd, atom_per_specie)
if not n_gcd:
- raise ValueError('The specified species do not exist in the structure'
- ' to be enumerated')
+ raise ValueError(
+ 'The specified species do not exist in the structure'
+ ' to be enumerated')
return lcm(n_gcd, denom) / n_gcd
View
2 pymatgen/util/string_utils.py
@@ -192,7 +192,7 @@ def max_width_col(table, col_idx):
def is_string(s):
"""True if s behaves like a string (duck typing test)."""
try:
- dummy = s + " "
+ s + " "
return True
except TypeError:
View
6 scripts/feff_input_generation.py
@@ -16,14 +16,10 @@
__date__ = "April 7, 2013"
import argparse
-import CifFile
-import abc
from pymatgen.io.feffio_set import *
from pymatgen.io.vaspio import *
-from pymatgen.io.feffio import *
-from pymatgen.io.cifio import CifParser, CifWriter
-from pymatgen.core.structure import Structure, Site, PeriodicSite
+from pymatgen.io.cifio import CifParser
parser = argparse.ArgumentParser(description='''
Example script to generate FEFF input files from a cif file

0 comments on commit d2392ca

Please sign in to comment.
Something went wrong with that request. Please try again.