Skip to content

Commit 96fb7c5

Browse files
authored
Merge pull request #149 from BCDA-APS/LGTM-more-148
fixes #148, more LGTM recommendations
2 parents 5e3d188 + cda663b commit 96fb7c5

File tree

4 files changed

+43
-24
lines changed

4 files changed

+43
-24
lines changed

apstools/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def get_versions():
495495
# versionfile_source is the relative path from the top of the source
496496
# tree (where the .git directory might live) to this file. Invert
497497
# this to find the root from __file__.
498-
for _i in cfg.versionfile_source.split('/'):
498+
for _ in cfg.versionfile_source.split('/'):
499499
root = os.path.dirname(root)
500500
except NameError:
501501
return {"version": "0+unknown", "full-revisionid": None,

apstools/callbacks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def __init__(self):
6767

6868
def receiver(self, key, document):
6969
"""keep all documents from recent plan in memory"""
70-
uid = document.get("uid", None) or document.get("datum_id", None)
71-
if "uid" is None:
70+
uid = document.get("uid") or document.get("datum_id")
71+
if uid is None:
7272
raise KeyError("No uid in '{}' document".format(key))
7373
self.uids.append(uid)
7474
logger = logging.getLogger(__name__)

apstools/synApps_ophyd/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,17 @@
3737
from .save_data import *
3838
from .sscan import *
3939
from .swait import *
40+
41+
__all__ = """
42+
busyRecord
43+
BusyStatus
44+
SaveData
45+
sscanRecord
46+
sscanDevice
47+
swaitRecord
48+
userCalcsDevice
49+
swait_setup_random_number
50+
swait_setup_gaussian
51+
swait_setup_lorentzian
52+
swait_setup_incrementer
53+
""".split()

apstools/synApps_ophyd/swait.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def swait_setup_random_number(swait, **kw):
187187
swait.read_attrs = ['val',]
188188

189189

190-
def swait_setup_gaussian(swait, motor, center=0, width=1, scale=1, noise=0.05):
191-
"""setup swait for noisy Gaussian"""
190+
def _setup_peak_swait_(calc, desc, swait, motor, center=0, width=1, scale=1, noise=0.05):
191+
"""internal: setup that is common to both Gaussian and Lorentzian swaits"""
192192
# consider a noisy background, as well (needs a couple calcs)
193193
assert(isinstance(motor, EpicsMotor))
194194
assert(width > 0)
@@ -200,33 +200,38 @@ def swait_setup_gaussian(swait, motor, center=0, width=1, scale=1, noise=0.05):
200200
swait.channels.C.value.put(width)
201201
swait.channels.D.value.put(scale)
202202
swait.channels.E.value.put(noise)
203-
swait.calc.put("D*(0.95+E*RNDM)/exp(((A-b)/c)^2)")
203+
swait.calc.put(calc)
204204
swait.scan.put("I/O Intr")
205-
swait.desc.put("noisy Gaussian curve")
205+
swait.desc.put(desc)
206206

207207
swait.hints = {"fields": ['val',]}
208208
swait.read_attrs = ['val',]
209209

210210

211+
def swait_setup_gaussian(swait, motor, center=0, width=1, scale=1, noise=0.05):
212+
"""setup swait for noisy Gaussian"""
213+
_setup_peak_swait_(
214+
"D*(0.95+E*RNDM)/exp(((A-b)/c)^2)",
215+
"noisy Gaussian curve",
216+
swait,
217+
motor,
218+
center=center,
219+
width=width,
220+
scale=scale,
221+
noise=noise)
222+
223+
211224
def swait_setup_lorentzian(swait, motor, center=0, width=1, scale=1, noise=0.05):
212225
"""setup swait record for noisy Lorentzian"""
213-
# consider a noisy background, as well (needs a couple calcs)
214-
assert(isinstance(motor, EpicsMotor))
215-
assert(width > 0)
216-
assert(0.0 <= noise <= 1.0)
217-
swait.reset()
218-
swait.scan.put("Passive")
219-
swait.channels.A.input_pv.put(motor.user_readback.pvname)
220-
swait.channels.B.value.put(center)
221-
swait.channels.C.value.put(width)
222-
swait.channels.D.value.put(scale)
223-
swait.channels.E.value.put(noise)
224-
swait.calc.put("D*(0.95+E*RNDM)/(1+((A-b)/c)^2)")
225-
swait.scan.put("I/O Intr")
226-
swait.desc.put("noisy Lorentzian curve")
227-
228-
swait.hints = {"fields": ['val',]}
229-
swait.read_attrs = ['val',]
226+
_setup_peak_swait_(
227+
"D*(0.95+E*RNDM)/(1+((A-b)/c)^2)",
228+
"noisy Lorentzian curve",
229+
swait,
230+
motor,
231+
center=center,
232+
width=width,
233+
scale=scale,
234+
noise=noise)
230235

231236

232237
def swait_setup_incrementer(swait, scan=None, limit=100000):

0 commit comments

Comments
 (0)