Loading openflexure_microscope/camera/pi.py +2 −2 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ class StreamingCamera(BaseCamera): for i in range(2): if np.abs(centre[i] - 0.5) + size/2 > 0.5: centre[i] = 0.5 + (1.0 - size)/2 * np.sign(centre[i]-0.5) print("setting zoom, centre {}, size {}".format(centre, size)) logging.info("setting zoom, centre {}, size {}".format(centre, size)) new_fov = (centre[0] - size/2, centre[1] - size/2, size, size) self.camera.zoom = new_fov Loading Loading @@ -328,7 +328,7 @@ class StreamingCamera(BaseCamera): return output else: print( logging.error( "Cannot start a new recording\ until the current recording has stopped.") return None Loading tests/test_camera.py +10 −31 Original line number Diff line number Diff line #!/usr/bin/env python from openflexure_microscope.camera.pi import StreamingCamera, CaptureObject import os import io import sys Loading @@ -15,16 +16,6 @@ from pprint import pprint import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) success_string = """ /O | | _____) \\ (__0) \\______ (____0) (____0) EVERYTHING IS OK! (__o)___________ """ class TestCaptureMethods(unittest.TestCase): Loading Loading @@ -291,7 +282,7 @@ class TestThreadStarting(unittest.TestCase): if __name__ == '__main__': camera = StreamingCamera() with StreamingCamera() as camera: suites = [ unittest.TestLoader().loadTestsFromTestCase(TestCaptureMethods), Loading @@ -303,15 +294,3 @@ if __name__ == '__main__': alltests = unittest.TestSuite(suites) result = unittest.TextTestRunner(verbosity=2).run(alltests) print("Objects created during tests:") # Show us what was captured for im in camera.images: pprint(im.metadata) for im in camera.videos: pprint(im.metadata) if result.wasSuccessful(): print(success_string) camera.close() tests/test_plugins.py +12 −27 Original line number Diff line number Diff line Loading @@ -10,15 +10,12 @@ import unittest import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) success_string = """ /O | | _____) \\ (__0) \\______ (____0) (____0) EVERYTHING IS OK! (__o)___________ """ OPENFLEXURERC = { 'plugins': [ 'openflexure_microscope.plugins.testing:Plugin' ] } class TestPluginMethods(unittest.TestCase): Loading @@ -40,15 +37,7 @@ class TestPluginMethods(unittest.TestCase): if __name__ == '__main__': openflexurerc = { 'plugins': [ 'openflexure_microscope.plugins.testing:Plugin' ] } with StreamingCamera() as camera, OpenFlexureStage("/dev/ttyUSB0") as stage: microscope = Microscope(camera, stage, openflexurerc) with Microscope(StreamingCamera(), OpenFlexureStage("/dev/ttyUSB0"), OPENFLEXURERC) as microscope: suites = [ unittest.TestLoader().loadTestsFromTestCase(TestPluginMethods), Loading @@ -58,7 +47,3 @@ if __name__ == '__main__': result = unittest.TextTestRunner(verbosity=2).run(alltests) if result.wasSuccessful(): print(success_string) microscope.close() No newline at end of file tests/test_microscope.py→tests/test_stage.py +4 −21 Original line number Diff line number Diff line Loading @@ -18,16 +18,6 @@ from pprint import pprint import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.INFO) success_string = """ /O | | _____) \\ (__0) \\______ (____0) (____0) EVERYTHING IS OK! (__o)___________ """ class TestMicroscope(unittest.TestCase): Loading @@ -35,16 +25,16 @@ class TestMicroscope(unittest.TestCase): move_distance = 500 for axis in range(3): for direction in [1, -1]: pos_i = microscope.stage.position pos_i = stage.position logging.debug(pos_i) logging.info("Moving axis {} by {}".format(axis, move_distance*direction)) move = [0, 0, 0] move[axis] = move_distance*direction microscope.stage.move_rel(move) stage.move_rel(move) pos_f = microscope.stage.position pos_f = stage.position diff = np.subtract(pos_f, pos_i) logging.debug("{} > {}".format(pos_i, pos_f)) Loading @@ -52,9 +42,7 @@ class TestMicroscope(unittest.TestCase): if __name__ == '__main__': with StreamingCamera() as camera, OpenFlexureStage("/dev/ttyUSB0") as stage: microscope = Microscope(camera, stage) with OpenFlexureStage("/dev/ttyUSB0") as stage: suites = [ unittest.TestLoader().loadTestsFromTestCase(TestMicroscope), Loading @@ -63,8 +51,3 @@ if __name__ == '__main__': alltests = unittest.TestSuite(suites) result = unittest.TextTestRunner(verbosity=2).run(alltests) if result.wasSuccessful(): print(success_string) microscope.close() No newline at end of file Loading
openflexure_microscope/camera/pi.py +2 −2 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ class StreamingCamera(BaseCamera): for i in range(2): if np.abs(centre[i] - 0.5) + size/2 > 0.5: centre[i] = 0.5 + (1.0 - size)/2 * np.sign(centre[i]-0.5) print("setting zoom, centre {}, size {}".format(centre, size)) logging.info("setting zoom, centre {}, size {}".format(centre, size)) new_fov = (centre[0] - size/2, centre[1] - size/2, size, size) self.camera.zoom = new_fov Loading Loading @@ -328,7 +328,7 @@ class StreamingCamera(BaseCamera): return output else: print( logging.error( "Cannot start a new recording\ until the current recording has stopped.") return None Loading
tests/test_camera.py +10 −31 Original line number Diff line number Diff line #!/usr/bin/env python from openflexure_microscope.camera.pi import StreamingCamera, CaptureObject import os import io import sys Loading @@ -15,16 +16,6 @@ from pprint import pprint import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) success_string = """ /O | | _____) \\ (__0) \\______ (____0) (____0) EVERYTHING IS OK! (__o)___________ """ class TestCaptureMethods(unittest.TestCase): Loading Loading @@ -291,7 +282,7 @@ class TestThreadStarting(unittest.TestCase): if __name__ == '__main__': camera = StreamingCamera() with StreamingCamera() as camera: suites = [ unittest.TestLoader().loadTestsFromTestCase(TestCaptureMethods), Loading @@ -303,15 +294,3 @@ if __name__ == '__main__': alltests = unittest.TestSuite(suites) result = unittest.TextTestRunner(verbosity=2).run(alltests) print("Objects created during tests:") # Show us what was captured for im in camera.images: pprint(im.metadata) for im in camera.videos: pprint(im.metadata) if result.wasSuccessful(): print(success_string) camera.close()
tests/test_plugins.py +12 −27 Original line number Diff line number Diff line Loading @@ -10,15 +10,12 @@ import unittest import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) success_string = """ /O | | _____) \\ (__0) \\______ (____0) (____0) EVERYTHING IS OK! (__o)___________ """ OPENFLEXURERC = { 'plugins': [ 'openflexure_microscope.plugins.testing:Plugin' ] } class TestPluginMethods(unittest.TestCase): Loading @@ -40,15 +37,7 @@ class TestPluginMethods(unittest.TestCase): if __name__ == '__main__': openflexurerc = { 'plugins': [ 'openflexure_microscope.plugins.testing:Plugin' ] } with StreamingCamera() as camera, OpenFlexureStage("/dev/ttyUSB0") as stage: microscope = Microscope(camera, stage, openflexurerc) with Microscope(StreamingCamera(), OpenFlexureStage("/dev/ttyUSB0"), OPENFLEXURERC) as microscope: suites = [ unittest.TestLoader().loadTestsFromTestCase(TestPluginMethods), Loading @@ -58,7 +47,3 @@ if __name__ == '__main__': result = unittest.TextTestRunner(verbosity=2).run(alltests) if result.wasSuccessful(): print(success_string) microscope.close() No newline at end of file
tests/test_microscope.py→tests/test_stage.py +4 −21 Original line number Diff line number Diff line Loading @@ -18,16 +18,6 @@ from pprint import pprint import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.INFO) success_string = """ /O | | _____) \\ (__0) \\______ (____0) (____0) EVERYTHING IS OK! (__o)___________ """ class TestMicroscope(unittest.TestCase): Loading @@ -35,16 +25,16 @@ class TestMicroscope(unittest.TestCase): move_distance = 500 for axis in range(3): for direction in [1, -1]: pos_i = microscope.stage.position pos_i = stage.position logging.debug(pos_i) logging.info("Moving axis {} by {}".format(axis, move_distance*direction)) move = [0, 0, 0] move[axis] = move_distance*direction microscope.stage.move_rel(move) stage.move_rel(move) pos_f = microscope.stage.position pos_f = stage.position diff = np.subtract(pos_f, pos_i) logging.debug("{} > {}".format(pos_i, pos_f)) Loading @@ -52,9 +42,7 @@ class TestMicroscope(unittest.TestCase): if __name__ == '__main__': with StreamingCamera() as camera, OpenFlexureStage("/dev/ttyUSB0") as stage: microscope = Microscope(camera, stage) with OpenFlexureStage("/dev/ttyUSB0") as stage: suites = [ unittest.TestLoader().loadTestsFromTestCase(TestMicroscope), Loading @@ -63,8 +51,3 @@ if __name__ == '__main__': alltests = unittest.TestSuite(suites) result = unittest.TextTestRunner(verbosity=2).run(alltests) if result.wasSuccessful(): print(success_string) microscope.close() No newline at end of file