Fix up ,select_config usage; now unit tests pass.
[pypiezo.git] / pypiezo / afm.py
index 8430ba65c2e00c7e918c0dac5f1e74196cafec79..616c6f4b6c3d039bf9b916ab961bca1a4dda6d6d 100644 (file)
@@ -73,8 +73,9 @@ class AFMPiezo (_base.Piezo):
 
     >>> axis_config = config.AxisConfig()
     >>> axis_config.update(
-    ...     {'name': 'z', 'gain':20, 'sensitivity':8e-9, 'minimum':-9})
+    ...     {'gain':20, 'sensitivity':8e-9, 'minimum':-9})
     >>> axis_config['channel'] = config.OutputChannelConfig()
+    >>> axis_config['channel']['name'] = 'z'
     >>> input_config = config.InputChannelConfig()
     >>> input_config['name'] = 'deflection'
 
@@ -84,7 +85,7 @@ class AFMPiezo (_base.Piezo):
     >>> c = _base.InputChannel(config=input_config, channel=input_channel)
     >>> c.setup_config()
 
-    >>> p = AFMPiezo(axes=[a], input_channels=[c], name='Molly')
+    >>> p = AFMPiezo(axes=[a], inputs=[c], name='Molly')
 
     >>> deflection = p.read_deflection()
     >>> deflection  # doctest: +SKIP
@@ -95,7 +96,8 @@ class AFMPiezo (_base.Piezo):
     We need to know where we are before we can move somewhere
     smoothly.
 
-    >>> pos = _base.convert_volts_to_bits(p.config['axes'][0]['channel'], 0)
+    >>> pos = _base.convert_volts_to_bits(p.config.select_config(
+    ...     'axes', 'z', get_attribute=_base.get_axis_name)['channel'], 0)
     >>> p.jump('z', pos)
 
     Usually `.move_to_pos_or_def` is used to approach the surface, but
@@ -103,9 +105,11 @@ class AFMPiezo (_base.Piezo):
     into the deflection input channel.
 
     >>> target_pos = _base.convert_volts_to_bits(
-    ...     p.config['axes'][0]['channel'], 2)
+    ...     p.config.select_config('axes', 'z',
+    ...     get_attribute=_base.get_axis_name)['channel'], 2)
     >>> step = int((target_pos - pos)/5)
-    >>> target_def = _base.convert_volts_to_bits(p.config['inputs'][0], 3)
+    >>> target_def = _base.convert_volts_to_bits(
+    ...     p.config.select_config('inputs', 'deflection'), 3)
     >>> data = p.move_to_pos_or_def('z', target_pos, target_def, step=step,
     ...     return_data=True)
     >>> p.last_output == {'z': int(target_pos)}
@@ -121,7 +125,7 @@ class AFMPiezo (_base.Piezo):
 
     >>> p.jump('z', pos)
     >>> target_def = _base.convert_volts_to_bits(
-    ...     p.config['inputs'][0]['channel'], 1)
+    ...     p.config.select_config('inputs', 'deflection'), 1)
     >>> data = p.move_to_pos_or_def('z', target_pos, target_def, step=step,
     ...     return_data=True)
     >>> print (p.last_output['z'] < int(target_pos))