Skip to content

Commit 32d4696

Browse files
committed
Improve python variable names to be more explicit
1 parent 17c1cd9 commit 32d4696

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

Framework/PythonInterface/plugins/algorithms/CylinderPaalmanPingsCorrection2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,11 @@ def _sum_rom(self, n_scat, n_abs, a, r1, r2, ms, theta, amu_scat, amu_tot_i, amu
790790
LIS.append(LISN - LIST)
791791
#
792792
# CALCULATE DISTANCE SCATTERED NEUTRON PASSES THROUGH EACH ANNULUS
793+
omega_scattered = omega + theta_deg
793794
LSS = []
794795
for j in range(0, nan):
795-
LSST = self._distance(r, self._radii[j], omega + theta_deg)
796-
LSSN = self._distance(r, self._radii[j + 1], omega + theta_deg)
796+
LSST = self._distance(r, self._radii[j], omega_scattered)
797+
LSSN = self._distance(r, self._radii[j + 1], omega_scattered)
797798
LSS.append(LSSN - LSST)
798799
#
799800
# CALCULATE ABSORPTION FOR PATH THROUGH ALL ANNULI,AND THROUGH INNER ANNULI

Framework/PythonInterface/plugins/algorithms/LoadNMoldyn3Ascii.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
# ==============================================================================
2121

2222

23-
def _find_starts(data, c, l1):
24-
for i in range(l1, len(data)):
23+
def _find_starts(data, c, start_i):
24+
for i in range(start_i, len(data)):
2525
char = data[i]
2626
if char.startswith(c):
2727
line = i
@@ -32,8 +32,8 @@ def _find_starts(data, c, l1):
3232
# ==============================================================================
3333

3434

35-
def _find_tab_starts(data, c, l1):
36-
for i in range(l1, len(data)):
35+
def _find_tab_starts(data, c, start_i):
36+
for i in range(start_i, len(data)):
3737
char = data[i][1:]
3838
if char.startswith(c):
3939
line = i
@@ -44,8 +44,8 @@ def _find_tab_starts(data, c, l1):
4444
# ==============================================================================
4545

4646

47-
def _find_ends(data, c, l1):
48-
for i in range(l1, len(data)):
47+
def _find_ends(data, c, start_i):
48+
for i in range(start_i, len(data)):
4949
char = data[i]
5050
if char.endswith(c):
5151
line = i
@@ -56,9 +56,9 @@ def _find_ends(data, c, l1):
5656
# ==============================================================================
5757

5858

59-
def _make_list(a, l1, l2):
59+
def _make_list(a, start_i, end_i):
6060
data = ""
61-
for m in range(l1, l2 + 1):
61+
for m in range(start_i, end_i + 1):
6262
data += a[m]
6363
alist = data.split(",")
6464
return alist

qt/python/mantidqtinterfaces/mantidqtinterfaces/drill/presenter/DrillPresenter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ def inc(value, i):
139139
if ":" in value:
140140
substrings = value.split(":")
141141
try:
142-
values = [int(e) for e in substrings]
142+
runs = [int(e) for e in substrings]
143143
except:
144144
return value
145-
if len(values) == 2:
145+
if len(runs) == 2:
146146
if i > 0:
147-
return str(values[1] + i) + ":" + str(values[1] + (values[1] - values[0]) + i)
147+
return str(runs[1] + i) + ":" + str(runs[1] + (runs[1] - runs[0]) + i)
148148
else:
149-
return str(values[0] - (values[1] - values[0]) + i) + ":" + str(values[0] + i)
150-
if len(values) == 3:
151-
return inc(str(values[0]) + ":" + str(values[1]), i) + ":" + str(values[2])
149+
return str(runs[0] - (runs[1] - runs[0]) + i) + ":" + str(runs[0] + i)
150+
if len(runs) == 3:
151+
return inc(str(runs[0]) + ":" + str(runs[1]), i) + ":" + str(runs[2])
152152
else:
153153
return value
154154

scripts/pychop/Instruments.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,10 @@ def getMeasuredFlux(self, Ei):
650650
"""Interpolates flux from a table of measured flux"""
651651
if not hasattr(self, "flux_interp"):
652652
raise AttributeError("This instrument does not have a table of measured flux")
653-
wavelength = [min(max(value, self.fmn), self.fmx) for value in np.sqrt(E2L / np.array(Ei if hasattr(Ei, "__len__") else [Ei]))]
654-
return self.flux_interp(wavelength[0])
653+
wavelengths = [
654+
min(max(wavelength, self.fmn), self.fmx) for wavelength in np.sqrt(E2L / np.array(Ei if hasattr(Ei, "__len__") else [Ei]))
655+
]
656+
return self.flux_interp(wavelengths[0])
655657

656658
@property
657659
def theta_m(self):

tools/CodeAnalysis/gcovr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -705,20 +705,20 @@ def print_xml_report(covdata): # noqa: C901
705705
class_lines += 1
706706
if hits > 0:
707707
class_hits += 1
708-
line = doc.createElement("line")
709-
line.setAttribute("number", str(line))
710-
line.setAttribute("hits", str(hits))
708+
line_element = doc.createElement("line")
709+
line_element.setAttribute("number", str(line))
710+
line_element.setAttribute("hits", str(hits))
711711
branches = data.branches.get(line)
712712
if branches is None:
713-
line.setAttribute("branch", "false")
713+
line_element.setAttribute("branch", "false")
714714
else:
715715
b_hits = 0
716716
for v in branches.values():
717717
if v > 0:
718718
b_hits += 1
719719
coverage = 100 * b_hits / len(branches)
720-
line.setAttribute("branch", "true")
721-
line.setAttribute("condition-coverage", "%i%% (%i/%i)" % (coverage, b_hits, len(branches)))
720+
line_element.setAttribute("branch", "true")
721+
line_element.setAttribute("condition-coverage", "%i%% (%i/%i)" % (coverage, b_hits, len(branches)))
722722
cond = doc.createElement("condition")
723723
cond.setAttribute("number", "0")
724724
cond.setAttribute("type", "jump")
@@ -727,9 +727,9 @@ def print_xml_report(covdata): # noqa: C901
727727
class_branches += float(len(branches))
728728
conditions = doc.createElement("conditions")
729729
conditions.appendChild(cond)
730-
line.appendChild(conditions)
730+
line_element.appendChild(conditions)
731731

732-
lines.appendChild(line)
732+
lines.appendChild(line_element)
733733

734734
className = fname.replace(".", "_")
735735
c.setAttribute("name", className)

0 commit comments

Comments
 (0)