Skip to content

Commit

Permalink
Refs #11268. Fix pylint problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed Jan 14, 2016
1 parent 69c5f65 commit ab265c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
42 changes: 21 additions & 21 deletions Framework/PythonInterface/plugins/algorithms/LoadCIF.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=no-init,invalid-name,too-few-public-methods,unused-import
# pylint: disable=no-init,too-few-public-methods
from mantid.kernel import *
from mantid.simpleapi import *
from mantid.api import *
Expand Down Expand Up @@ -30,14 +30,16 @@ def getCrystalStructure(self):
def _getSpaceGroup(self, cifData):
try:
return self._getSpaceGroupFromString(cifData)
# pylint: disable=unused-variable
except (RuntimeError, ValueError) as error:
try:
return self._getSpaceGroupFromNumber(cifData)
# pylint: disable=unused-variable,invalid-name
except RuntimeError as e:
raise RuntimeError(
'Can not create space group from supplied CIF-file. You could try to modify the HM-symbol' \
'to contain spaces between the components.\n' \
'Keys to look for: _space_group_name_H-M_alt, _symmetry_space_group_name_H-M')
'Can not create space group from supplied CIF-file. You could try to modify the HM-symbol'\
'to contain spaces between the components.\n'\
'Keys to look for: _space_group_name_H-M_alt, _symmetry_space_group_name_H-M')

def _getSpaceGroupFromString(self, cifData):
# Try two possibilities for space group symbol. If neither is present, throw a RuntimeError.
Expand Down Expand Up @@ -70,17 +72,16 @@ def _getSpaceGroupFromNumber(self, cifData):

if len(possibleSpaceGroupSymbols) != 1:
raise RuntimeError(
'Can not use space group number to determine space group for no. {0}'.format(spaceGroupNumber))
'Can not use space group number to determine space group for no. {0}'.format(spaceGroupNumber))

return SpaceGroupFactory.createSpaceGroup(possibleSpaceGroupSymbols[0]).getHMSymbol()

def _getUnitCell(self, cifData):
unitCellComponents = [u'_cell_length_a', u'_cell_length_b', u'_cell_length_c',
u'_cell_angle_alpha', u'_cell_angle_beta', u'_cell_angle_gamma']

unitCellValueMap = dict(
[(str(x), str(cifData[x])) if x in cifData.keys() else (str(x), None) for x in
unitCellComponents])
unitCellValueMap = dict([(str(x), str(cifData[x])) if x in cifData.keys() else (str(x), None) for x in
unitCellComponents])

if unitCellValueMap['_cell_length_a'] is None:
raise RuntimeError('The a-parameter of the unit cell is not specified in the supplied CIF.\n' \
Expand Down Expand Up @@ -113,8 +114,8 @@ def _getAtoms(self, cifData):
else:
if required:
raise RuntimeError(
'Mandatory field {0} not found in CIF-file.' \
'Please check the atomic position definitions.'.format(field))
'Mandatory field {0} not found in CIF-file.' \
'Please check the atomic position definitions.'.format(field))

atomLists = [cifData[x] for x in atomFields]

Expand All @@ -134,7 +135,7 @@ def _getCleanAtomSymbol(self, atomSymbol):


class UBMatrixBuilder(object):
def __init__(self, cifFile = None):
def __init__(self, cifFile=None):
if cifFile is not None:
cifData = cifFile[cifFile.keys()[0]]

Expand Down Expand Up @@ -168,20 +169,20 @@ def summary(self):

def PyInit(self):
self.declareProperty(
FileProperty(name='InputFile',
defaultValue='',
action=FileAction.Load,
extensions=['cif']),
doc='A CIF file containing a crystal structure.')
FileProperty(name='InputFile',
defaultValue='',
action=FileAction.Load,
extensions=['cif']),
doc='A CIF file containing a crystal structure.')

self.declareProperty('LoadUBMatrix', False,
direction=Direction.Input,
doc='Load UB-matrix from CIF file if available.')

self.declareProperty(
WorkspaceProperty(name='Workspace',
defaultValue='', direction=Direction.InOut),
doc='Workspace into which the crystal structure is placed.')
WorkspaceProperty(name='Workspace',
defaultValue='', direction=Direction.InOut),
doc='Workspace into which the crystal structure is placed.')

def PyExec(self):
cifFileName = self.getProperty('InputFile').value
Expand All @@ -204,8 +205,7 @@ def _getCrystalStructureFromCifFile(self, cifFile):
builder = CrystalStructureBuilder(cifFile)
crystalStructure = builder.getCrystalStructure()

self.log().information(
'''Loaded the following crystal structure:
self.log().information('''Loaded the following crystal structure:
Unit cell: {0}
Space group: {1}
Atoms: {2}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=no-init,invalid-name,too-many-public-methods
# pylint: disable=no-init,too-many-public-methods,invalid-name,protected-access
import unittest
from testhelpers import assertRaisesNothing

Expand Down Expand Up @@ -39,7 +39,6 @@ def test_getSpaceGroupFromString_valid_correct_value(self):
self.assertEqual(self.builder._getSpaceGroupFromString(merge_dicts(valid_new, invalid_old)), 'P m -3 m')

def test_getSpaceGroupFromString_invalid(self):
valid_new = {u'_space_group_name_h-m_alt': u'P m -3 m'}
valid_old = {u'_symmetry_space_group_name_h-m': u'P m -3 m'}
invalid_new = {u'_space_group_name_h-m_alt': u'invalid'}
invalid_old = {u'_symmetry_space_group_name_h-m': u'invalid'}
Expand Down

0 comments on commit ab265c4

Please sign in to comment.