ophyd icon indicating copy to clipboard operation
ophyd copied to clipboard

Child Attribute Selection

Open teddyrendahl opened this issue 6 years ago • 3 comments

Having some issues with selecting read_attrs of a child component. Here is some code to reproduce what I'm seeing. This gives me inconsistent results:

from ophyd import Device, Component as Cpt 
from ophyd.sim import SynAxis


class MyDevice(Device):
    x = Cpt(SynAxis)
    y = Cpt(SynAxis)
    z = Cpt(SynAxis)

    _default_read_attrs = ['x.readback', 'y.readback', 'z.readback',
                           'x.setpoint', 'y.setpoint', 'z.setpoint']


print(MyDevice(name='test').read_attrs)

Output:

$ python blah.py 
['x', 'x.readback', 'x.setpoint', 'y', 'y.readback', 'z', 'z.setpoint']
$ python blah.py 
['x', 'x.setpoint', 'y', 'y.readback', 'y.setpoint', 'z', 'z.setpoint']
$ python blah.py 
['x', 'x.readback', 'x.setpoint', 'y', 'y.setpoint', 'z', 'z.setpoint']

It seems like things are getting confused with the redundant naming of a motor and its signal. This also raises the question on what the best way to indicate that you want a read_attr that is component of a compnent using the Kind syntax.

teddyrendahl avatar Jun 18 '18 17:06 teddyrendahl

Well, that is deeply wrong...

I suspect the bug is in here

https://github.com/NSLS-II/ophyd/blob/07ab0b2cfc9fa3c5c35989fd58068df686100304/ophyd/device.py#L834-L844

tacaswell avatar Jun 18 '18 21:06 tacaswell

Has this been solved?

teddyrendahl avatar Sep 05 '18 18:09 teddyrendahl

not to my knowledge.

tacaswell avatar Sep 05 '18 18:09 tacaswell