microsoft / microsoft/Qcodes

Functions silently overwritten in Instrument

Open
#1,197 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
459
Forks
359
Avg merge
3d 6h
Merged PRs (30d)
73

Description

### Steps to reproduce

```python
from qcodes.instrument.base import Instrument
from qcodes.instrument.function import Function

class MyInst(Instrument):

def __init__(self, name):
super().__init__(name)

self.add_parameter('start', get_cmd="I'm a parameter")
self.add_function('start', call_cmd="I'm a function")

def write(self, cmd):
print(cmd)

def ask(self, cmd):
print(cmd)

myinst = MyInst('myinst')

myinst.start()
```

### Expected behaviour
Since both functions and parameters get delegated as attributes in the same way, it should not be possible to add a parameter with the name of an existing function of vice versa.

### Actual behaviour
The function gets ignored in favour of the parameter. I found a comment indicating that this is by design https://github.com/QCoDeS/Qcodes/blob/cfc97ec2090ed3620634affa3177419dddb6abae/qcodes/tests/test_instrument.py#L75. I don't think this is such a good design decision.

### Proposed solution

Maybe just get rid of the functions altogether?

### System
**operating system**
Windows 10

**qcodes branch**
master

**qcodes commit**
cfc97ec2090ed3620634affa3177419dddb6abae

Contributor guide

Open the contributing guide

Research direction

Start by reading qcodes/instrument/base.py and qcodes/instrument/function.py, then inspect the existing behavior noted in qcodes/tests/test_instrument.py. Determine how collisions between parameters and functions should be handled, and add coverage showing that neither is silently overwritten once the intended behavior is decided.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.