Repository: bluesky/bluesky-darkframes

Issue:
Add detector argument to dark_plan()
Pass the detector from DarkFramePreprocessor to dark_plan().

Discussion:

Patch:
diff --git a/.travis.yml b/.travis.yml
index f6314f9..acc748e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,8 @@ env:
 
 
 install:
+  # explicitly upgrade numpy to work around a problem with imagecodecs
+  - pip install --upgrade numpy
   # Install this package and the packages listed in requirements.txt.
   - pip install .
   # Install extra requirements for running tests and building docs.
diff --git a/bluesky_darkframes/__init__.py b/bluesky_darkframes/__init__.py
index 3806759..90f686d 100644
--- a/bluesky_darkframes/__init__.py
+++ b/bluesky_darkframes/__init__.py
@@ -97,7 +97,7 @@ class DarkFramePreprocessor:
     Parameters
     ----------
     dark_plan: callable
-        Expected siganture: ``dark_plan() -> snapshot_device``
+        Expected siganture: ``dark_plan(detector) -> snapshot_device``
     detector : Device
     max_age: float
         Time after which a fresh dark frame should be acquired
@@ -208,11 +208,11 @@ class DarkFramePreprocessor:
             try:
                 snapshot = self.get_snapshot(state)
             except NoMatchingSnapshot:
-                logger.info(f"Taking a new dark frame for state=%r", state)
-                snapshot = yield from self.dark_plan()
+                logger.info("Taking a new dark frame for state=%r", state)
+                snapshot = yield from self.dark_plan(self.detector)
                 self.add_snapshot(snapshot, state)
             if snapshot_changed or force_read:
-                logger.info(f"Creating a 'dark' Event for state=%r", state)
+                logger.info("Creating a 'dark' Event for state=%r", state)
                 self._current_snapshot.set_snaphsot(snapshot)
                 # Read the Snapshot into the 'dark' Event stream.
                 yield from bps.stage(self._current_snapshot)
diff --git a/docs/source/usage.rst b/docs/source/usage.rst
index 68f8dbe..22012a8 100644
--- a/docs/source/usage.rst
+++ b/docs/source/usage.rst
@@ -105,11 +105,11 @@ for whether/how dark frames can be reused.)
    det = DiffractionDetector(name='det')
    shutter = Shutter(name='shutter', value='open')
 
-   def dark_plan():
+   def dark_plan(detector):
        yield from bps.mv(shutter, 'closed')
-       yield from bps.trigger(det, group='darkframe-trigger')
+       yield from bps.trigger(detector, group='darkframe-trigger')
        yield from bps.wait('darkframe-trigger')
-       snapshot = bluesky_darkframes.SnapshotDevice(det)
+       snapshot = bluesky_darkframes.SnapshotDevice(detector)
        yield from bps.mv(shutter, 'open')
        return snapshot
 


Test patch:
diff --git a/bluesky_darkframes/tests/tests.py b/bluesky_darkframes/tests/tests.py
index eb56fbf..ff0f768 100644
--- a/bluesky_darkframes/tests/tests.py
+++ b/bluesky_darkframes/tests/tests.py
@@ -17,11 +17,11 @@ det.exposure_time.put(0.01)
 shutter = bluesky_darkframes.sim.Shutter(name='shutter', value='open')
 
 
-def dark_plan():
+def dark_plan(detector):
     yield from bps.mv(shutter, 'closed')
-    yield from bps.trigger(det, group='darkframe-trigger')
+    yield from bps.trigger(detector, group='darkframe-trigger')
     yield from bps.wait('darkframe-trigger')
-    snapshot = bluesky_darkframes.SnapshotDevice(det)
+    snapshot = bluesky_darkframes.SnapshotDevice(detector)
     yield from bps.mv(shutter, 'open')
     return snapshot