Skip to content

Commit c65c79b

Browse files
committedJan 31, 2016
Remove unused imports and unused local variables.
Stuff reported by pyflakes.
1 parent a7bf4bb commit c65c79b

25 files changed

+30
-45
lines changed
 

‎diffpy/Structure/Parsers/P_bratoms.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
"""Parser for Bruce Ravel's Atoms structure format
1717
"""
1818

19-
import sys
20-
import numpy
21-
2219
from diffpy.Structure import Lattice, Atom, StructureFormatError
2320
from diffpy.Structure.bratomsstructure import BRAtomsStructure
2421
from diffpy.Structure.Parsers import StructureParser
@@ -44,7 +41,6 @@ def parseLines(self, lines):
4441
atoms = []
4542
title = ""
4643
anext = False
47-
sg = None
4844
structure = BRAtomsStructure()
4945
meta = structure.bratoms
5046
pdict = dict.fromkeys(self.plist)
@@ -134,7 +130,7 @@ def parseLines(self, lines):
134130

135131
atoms.append(a)
136132

137-
except (ValueError, IndexError), e:
133+
except (ValueError, IndexError):
138134
emsg = "%d: file is not in Atoms format" % ln
139135
raise StructureFormatError(emsg)
140136

‎diffpy/Structure/Parsers/P_discus.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
"""
1818

1919
import sys
20-
import numpy
2120

22-
from diffpy.Structure import PDFFitStructure, Lattice, Atom
21+
from diffpy.Structure import PDFFitStructure, Lattice
2322
from diffpy.Structure import StructureFormatError
2423
from diffpy.Structure.Parsers import StructureParser
2524

‎diffpy/Structure/Parsers/P_pdb.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import numpy
2626
from numpy import pi
2727

28-
from diffpy.Structure import Structure, Lattice, Atom
28+
from diffpy.Structure import Structure
2929
from diffpy.Structure import StructureFormatError
3030
from diffpy.Structure.Parsers import StructureParser
3131

@@ -117,7 +117,6 @@ def parseLines(self, lines):
117117
elif record in ("ATOM", "HETATM"):
118118
name = line[12:16].strip()
119119
rc = [float(x) for x in line[30:54].split()]
120-
xyz = numpy.dot(scale, rc) + scaleU
121120
try:
122121
occupancy = float(line[54:60])
123122
except ValueError:

‎diffpy/Structure/Parsers/P_pdffit.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import sys
2020
import numpy
2121

22-
from diffpy.Structure import PDFFitStructure, Lattice, Atom
22+
from diffpy.Structure import PDFFitStructure, Lattice
2323
from diffpy.Structure import StructureFormatError
2424
from diffpy.Structure.Parsers import StructureParser
2525

@@ -42,7 +42,6 @@ def parseLines(self, lines):
4242
Return Structure object or raise StructureFormatError.
4343
"""
4444
p_nl = 0
45-
rlist = []
4645
try:
4746
self.stru = PDFFitStructure()
4847
stru = self.stru

‎diffpy/Structure/Parsers/P_rawxyz.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import sys
2222

23-
from diffpy.Structure import Structure, Lattice, Atom
23+
from diffpy.Structure import Structure
2424
from diffpy.Structure import StructureFormatError
2525
from diffpy.Structure.utils import isfloat
2626
from diffpy.Structure.Parsers import StructureParser

‎diffpy/Structure/Parsers/P_xcfg.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import re
2020
import numpy
2121

22-
from diffpy.Structure import Structure, Lattice, Atom
22+
from diffpy.Structure import Structure
2323
from diffpy.Structure import StructureFormatError
2424
from diffpy.Structure.utils import isfloat
2525
from diffpy.Structure.Parsers import StructureParser
@@ -174,7 +174,6 @@ def parseLines(self, lines):
174174
xcfg_H0_set = numpy.zeros((3,3), dtype=bool)
175175
xcfg_NO_VELOCITY = False
176176
xcfg_entry_count = None
177-
xcfg_auxiliary = []
178177
p_nl = 0
179178
p_auxiliary_re = re.compile(r"^auxiliary\[(\d+)\] =")
180179
p_auxiliary = {}

‎diffpy/Structure/Parsers/P_xyz.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import sys
2323

24-
from diffpy.Structure import Structure, Lattice, Atom
24+
from diffpy.Structure import Structure
2525
from diffpy.Structure import StructureFormatError
2626
from diffpy.Structure.Parsers import StructureParser
2727

‎diffpy/Structure/Parsers/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def getParser(format):
4343
emsg = "no parser for '%s' format" % format
4444
raise StructureFormatError(emsg)
4545
pmod = parser_index[format]['module']
46+
pm = None
4647
import_cmd = 'from diffpy.Structure.Parsers import %s as pm' % pmod
4748
exec(import_cmd)
4849
return pm.getParser()

‎diffpy/Structure/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
# interface definitions
3131
##############################################################################
3232

33-
from diffpy.Structure.StructureErrors import *
33+
from diffpy.Structure.StructureErrors import (StructureFormatError,
34+
LatticeError, SymmetryError, IsotropyError)
3435
from diffpy.Structure.atom import Atom
3536
from diffpy.Structure.lattice import Lattice
3637
from diffpy.Structure.structure import Structure

‎diffpy/Structure/applications/transtru.py

-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
"""
3333

3434
import sys
35-
import os
36-
import re
3735

3836
from diffpy.Structure import Structure, StructureFormatError
3937

@@ -54,7 +52,6 @@ def usage(style = None):
5452

5553
def version():
5654
from diffpy.Structure import __version__
57-
print __id__
5855
print "diffpy.Structure", __version__
5956

6057
def main():

‎diffpy/Structure/atom.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import numpy
2020
from diffpy.Structure.lattice import cartesian as cartesian_lattice
21-
from diffpy.Structure import IsotropyError
2221

2322
# conversion constants
2423
_BtoU = 1.0/(8 * numpy.pi**2)

‎diffpy/Structure/expansion/makeEllipsoid.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from math import ceil
1919
from numpy import array
20-
from diffpy.Structure import Structure, Atom
20+
from diffpy.Structure import Structure
2121
from diffpy.Structure.expansion.shapeUtils import findCenter
2222

2323
def makeSphere(S, radius):

‎diffpy/Structure/expansion/shapeUtils.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def findCenter(S):
3636

3737

3838
if __name__ == "__main__":
39+
# FIXME ... remove or convert to unit test
3940
import os.path
4041
datadir = "../../tests/testdata"
4142
S = Structure()

‎diffpy/Structure/lattice.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"""
2222

2323
import math
24-
import types
2524
import numpy
2625
import numpy.linalg as numalg
2726
from diffpy.Structure import LatticeError
@@ -172,12 +171,12 @@ def setLatPar(self, a=None, b=None, c=None,
172171
self._car = car = (cb*cg - ca)/(sb*sg)
173172
self._cbr = cbr = (ca*cg - cb)/(sa*sg)
174173
self._cgr = cgr = (ca*cb - cg)/(sa*sb)
175-
self._sar = sar = math.sqrt(1.0 - car*car)
176-
self._sbr = sbr = math.sqrt(1.0 - cbr*cbr)
174+
self._sar = math.sqrt(1.0 - car*car)
175+
self._sbr = math.sqrt(1.0 - cbr*cbr)
177176
self._sgr = sgr = math.sqrt(1.0 - cgr*cgr)
178-
self._alphar = alphar = math.degrees(math.acos(car))
179-
self._betar = betar = math.degrees(math.acos(cbr))
180-
self._gammar = gammar = math.degrees(math.acos(cgr))
177+
self._alphar = math.degrees(math.acos(car))
178+
self._betar = math.degrees(math.acos(cbr))
179+
self._gammar = math.degrees(math.acos(cgr))
181180
# metric tensor
182181
self.metrics = numpy.array( [
183182
[ self.a*self.a, self.a*self.b*cg, self.a*self.c*cb ],
@@ -239,8 +238,8 @@ def setLatBase(self, base):
239238
self._car = car = (cb*cg - ca)/(sb*sg)
240239
self._cbr = cbr = (ca*cg - cb)/(sa*sg)
241240
self._cgr = cgr = (ca*cb - cg)/(sa*sb)
242-
self._sar = sar = math.sqrt(1.0 - car**2)
243-
self._sbr = sbr = math.sqrt(1.0 - cbr**2)
241+
self._sar = math.sqrt(1.0 - car**2)
242+
self._sbr = math.sqrt(1.0 - cbr**2)
244243
self._sgr = sgr = math.sqrt(1.0 - cgr**2)
245244
self._alphar = math.degrees(math.acos(car))
246245
self._betar = math.degrees(math.acos(cbr))

‎diffpy/Structure/tests/TestLattice.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ def assertListAlmostEqual(self, l1, l2, places=None):
4242
def test_setLatPar(self):
4343
"""check calculation of standard unit cell vectors"""
4444
from numpy import dot
45-
from math import radians, sqrt, cos, sin
45+
from math import radians, sqrt, cos
4646
norm = lambda x : sqrt(sum([xi**2 for xi in x]))
4747
cosd = lambda x : cos(radians(x))
48-
sind = lambda x : sin(radians(x))
4948
self.lattice.setLatPar(1.0, 2.0, 3.0, 80, 100, 120)
5049
base = self.lattice.base
5150
self.assertAlmostEqual(1.0, norm(base[0]), self.places)

‎diffpy/Structure/tests/TestP_cif.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
"""Unit tests for diffpy.Structure.Parsers.P_cif module
1717
"""
1818

19-
import os
2019
import unittest
2120

2221
from diffpy.Structure.tests.testutils import datafile
23-
from diffpy.Structure.Parsers.P_cif import *
22+
from diffpy.Structure.Parsers.P_cif import P_cif, leading_float, getSymOp
2423
from diffpy.Structure import Structure
2524
from diffpy.Structure import StructureFormatError
2625

‎diffpy/Structure/tests/TestP_discus.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"""
1818

1919
import unittest
20-
import os
2120
import re
2221

2322
from diffpy.Structure.tests.testutils import datafile

‎diffpy/Structure/tests/TestP_pdffit.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"""
1818

1919
import unittest
20-
import os
2120
import re
2221

2322
from diffpy.Structure.tests.testutils import datafile

‎diffpy/Structure/tests/TestParsers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def test_writeStr_cif(self):
284284
"""check conversion to CIF string"""
285285
stru = self.stru
286286
stru.read(datafile('GaAs.inp'), 'bratoms')
287-
s_s = stru.writeStr(self.format)
287+
stru.writeStr(self.format)
288288

289289
def test_read_bratoms_bad(self):
290290
"""check exceptions when reading invalid bratoms file"""

‎diffpy/Structure/tests/TestStructure.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
"""
1818

1919

20-
import os
2120
import copy
2221
import unittest
2322
import numpy
2423

2524
from diffpy.Structure.tests.testutils import datafile
26-
from diffpy.Structure import Structure, StructureFormatError
25+
from diffpy.Structure import Structure
2726
from diffpy.Structure import Lattice
2827
from diffpy.Structure import Atom
2928

‎diffpy/Structure/tests/TestSuperCell.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"""
1818

1919

20-
import os
2120
import unittest
2221

2322
from diffpy.Structure.tests.testutils import datafile

‎diffpy/Structure/tests/TestSymmetryUtilities.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
"""Unit tests for SymmetryUtilities.py
1717
"""
1818

19-
import os
2019
import sys
2120
import unittest
2221
import numpy
2322

24-
from diffpy.Structure.tests.testutils import datafile
2523
from diffpy.Structure.SpaceGroups import GetSpaceGroup
26-
from diffpy.Structure.SymmetryUtilities import *
24+
from diffpy.Structure.SymmetryUtilities import (isSpaceGroupLatPar,
25+
expandPosition, pruneFormulaDictionary, isconstantFormula,
26+
GeneratorSite, ExpandAsymmetricUnit, SymmetryConstraints)
2727
from diffpy.Structure.SymmetryUtilities import _Position2Tuple
2828

2929
##############################################################################
@@ -202,7 +202,6 @@ def test_positionFormula(self):
202202
self.assertEqual([("x", self.x)], self.g117h.pparameters)
203203
# 143c
204204
pfm143c = self.g143c.positionFormula(self.g143c.xyz)
205-
places = 12
206205
self.assertEqual("+2/3", pfm143c["x"])
207206
self.assertEqual("+1/3", pfm143c["y"])
208207
self.assertEqual("z", pfm143c["z"])

‎diffpy/Structure/tests/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def testsuite():
3535
'''.split()
3636
suite = unittest.TestSuite()
3737
loader = unittest.defaultTestLoader
38+
mobj = None
3839
for mname in modulenames:
3940
exec ('import %s as mobj' % mname)
4041
suite.addTests(loader.loadTestsFromModule(mobj))

‎diffpy/Structure/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
def isfloat(s):
2323
"""True if argument can be converted to float"""
2424
try:
25-
x = float(s)
25+
float(s)
2626
return True
2727
except ValueError:
2828
pass

‎setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
versioncfgfile = os.path.join(MYDIR, 'diffpy/Structure/version.cfg')
1919
gitarchivecfgfile = versioncfgfile.replace('version.cfg', 'gitarchive.cfg')
2020

21+
2122
def gitinfo():
2223
from subprocess import Popen, PIPE
2324
kw = dict(stdout=PIPE, cwd=MYDIR)
@@ -85,7 +86,7 @@ def getversioncfg():
8586
maintainer = 'Pavol Juhas',
8687
maintainer_email = 'pavol.juhas@gmail.com',
8788
url = 'https://github.com/diffpy/diffpy.Structure',
88-
description = "Crystal structure container " + \
89+
description = "Crystal structure container "
8990
"and parsers for structure formats.",
9091
license = 'BSD-style license',
9192
keywords = "crystal Structure data storage CIF PDB",

0 commit comments

Comments
 (0)
Please sign in to comment.