Commit ebda3a57 authored by Shahroz Ahmed's avatar Shahroz Ahmed
Browse files

enabled unused-variable and its fixes on reducer & geo.._writer

refs #15172
parent a2d18947
# pylint: disable=invalid-name,unused-variable, too-many-arguments
# pylint: disable=invalid-name
from xml.dom.minidom import getDOMImplementation
from datetime import datetime
import re
......@@ -142,9 +142,7 @@ class MantidGeom(object):
def addMonitors(self, distance=None, names=None):
self.list_func(distance)
self.list_func(names)
"""
Add a list of monitors to the geometry.
"""
# Add a list of monitors to the geometry.
if len(distance) != len(names):
raise IndexError("Distance and name list must be same size!")
......@@ -156,7 +154,7 @@ class MantidGeom(object):
basecomponent.setAttribute("mark-as", "monitor")
for i in range(len(distance)):
zi = float(distance[i])
dummy_zi = float(distance[i])
self._append_child("location", basecomponent, z=distance[i], name=names[i])
def addComponent(self, type_name, idlist=None, root=None, blank_location=True):
......@@ -211,7 +209,7 @@ class MantidGeom(object):
self.addLocation(comp_element, x, y, z, rot_x, rot_y, rot_z)
def addSingleDetector(self, root, x, y, z, rot_x, rot_y, rot_z, name=None,
id=None, usepolar=None):
_id=None, usepolar=None):
"""
Add a single detector by explicit declaration. The rotation order is
performed as follows: y, x, z.
......@@ -251,17 +249,17 @@ class MantidGeom(object):
def addLocationPolar(self, root, r, theta, phi, name=None):
if name is not None:
pos_loc = self._append_child("location", root, r=r, t=theta, p=phi, name=name)
_pos_loc = self._append_child("location", root, r=r, t=theta, p=phi, name=name)
else:
pos_loc = self._append_child("location", root, r=r, t=theta, p=phi)
_pos_loc = self._append_child("location", root, r=r, t=theta, p=phi)
def addLocationRTP(self, root, r, t, p, rot_x, rot_y, rot_z, name=None):
"""
Add a location element to a specific parent node given by root, using r, theta, phi coordinates.
"""
rf = float(r)
tf = float(f)
pf = float(p)
dummy_rf = float(r)
dummy_tf = float(f)
dummy_pf = float(p)
if name is not None:
pos_loc = self._append_child("location", root, r=r, t=t, p=p, name=name)
else:
......@@ -271,15 +269,15 @@ class MantidGeom(object):
# the combined rotation is equals that obtained by applying rotx, then roty and finally rotz.
if rot_x is not None:
log = self._append_child("parameter", pos_loc, name="rotx")
rotxf = float(rot_x)
_rotxf = float(rot_x)
self._append_child("value", log, val=rot_x)
if rot_y is not None:
log = self._append_child("parameter", pos_loc, name="roty")
rotyf = float(rot_y)
_rotyf = float(rot_y)
self._append_child("value", log, val=rot_y)
if rot_z is not None:
log = self._append_child("parameter", pos_loc, name="rotz")
rotzf = float(rot_z)
_rotzf = float(rot_z)
self._append_child("value", log, val=rot_z)
def addNPack(self, name, num_tubes, tube_width, air_gap, type_name="tube"):
......@@ -408,9 +406,8 @@ class MantidGeom(object):
def addMonitorIds(self, ids=None):
self.list_func(ids)
"""
Add the monitor IDs.
"""
# Add the monitor IDs.
idElt = self._append_child("idlist", self._root, idname="monitors")
for i in range(len(ids)):
self._append_child("id", idElt, val=ids[i])
......
......@@ -37,12 +37,12 @@ from reduction.find_data import find_data
__version__ = '1.0'
def validate_loader(f):
def validate_loader(func):
def validated_f(reducer, algorithm, *args, **kwargs):
if issubclass(algorithm.__class__, ReductionStep) or algorithm is None:
# If we have a ReductionStep object, just use it.
# "None" is allowed as an algorithm (usually tells the reducer to skip a step)
return f(reducer, algorithm)
return func(reducer, algorithm)
if isinstance(algorithm, types.FunctionType):
# If we get a function, assume its name is an algorithm name
......@@ -113,7 +113,7 @@ def validate_loader(f):
return alg.getPropertyValue("OutputMessage")
return "%s applied" % alg.name()
return f(reducer, _AlgorithmStep())
return func(reducer, _AlgorithmStep())
elif isinstance(algorithm, mantid.api.IAlgorithm) \
or type(algorithm).__name__ == "IAlgorithm":
......@@ -167,15 +167,15 @@ def validate_loader(f):
algorithm.execute()
return "%s applied" % algorithm.name()
return f(reducer, _AlgorithmStep())
return func(reducer, _AlgorithmStep())
else:
raise RuntimeError, "%s expects a ReductionStep object, found %s" % (f.__name__, algorithm.__class__)
raise RuntimeError, "%s expects a ReductionStep object, found %s" % (func.__name__, algorithm.__class__)
return validated_f
def validate_step(f):
def validate_step(func):
"""
Decorator for Reducer methods that need a ReductionStep
object as its first argument.
......@@ -196,7 +196,7 @@ def validate_step(f):
def validated_f(reducer, algorithm, *args, **kwargs):
"""
Wrapper function around the function f.
Wrapper function around the function func.
The function ensures that the algorithm parameter
is a sub-class of ReductionStep
@param algorithm: algorithm name, ReductionStep object, or Mantid algorithm function
......@@ -204,7 +204,7 @@ def validate_step(f):
if issubclass(algorithm.__class__, ReductionStep) or algorithm is None:
# If we have a ReductionStep object, just use it.
# "None" is allowed as an algorithm (usually tells the reducer to skip a step)
return f(reducer, algorithm)
return func(reducer, algorithm)
if isinstance(algorithm, types.FunctionType):
# If we get a function, assume its name is an algorithm name
......@@ -261,7 +261,7 @@ def validate_step(f):
return alg.getPropertyValue("OutputMessage")
return "%s applied" % alg.name()
return f(reducer, _AlgorithmStep())
return func(reducer, _AlgorithmStep())
elif isinstance(algorithm, mantid.api.IAlgorithm) \
or type(algorithm).__name__ == "IAlgorithm":
......@@ -303,10 +303,10 @@ def validate_step(f):
return algorithm.getPropertyValue("OutputMessage")
return "%s applied" % algorithm.name()
return f(reducer, _AlgorithmStep())
return func(reducer, _AlgorithmStep())
else:
raise RuntimeError, "%s expects a ReductionStep object, found %s" % (f.__name__, algorithm.__class__)
raise RuntimeError, "%s expects a ReductionStep object, found %s" % (func.__name__, algorithm.__class__)
return validated_f
......@@ -529,10 +529,10 @@ class Reducer(object):
self.log_text += "Log saved to %s" % log_path
# Write the log to file
f = open(log_path, 'a')
f.write("\n-------------------------------------------\n")
f.write(self.log_text)
f.close()
file_dat = open(log_path, 'a')
file_dat.write("\n-------------------------------------------\n")
file_dat.write(self.log_text)
file_dat.close()
return self.log_text
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment