internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: microsoft/Qcodes

Issue:
Confusing error message when pickling an instrument
The error message raised when pickling an instrument references the old `Loops` which is confusing to modern users.

https://github.com/QCoDeS/Qcodes/blob/66222eb8cc4ab1ab2cdadb94da827f94436b4af7/qcodes/instrument/base.py#L368-L375

I propose that we shorten the error message down to "QCoDeS instruments can not be pickled".

Maybe this is something for @Akshita07 to look into?


Discussion:

Resolving patch:
diff --git a/qcodes/instrument/base.py b/qcodes/instrument/base.py
--- a/qcodes/instrument/base.py
+++ b/qcodes/instrument/base.py
@@ -368,11 +368,8 @@ def call(self, func_name: str, *args: Any) -> Any:
     def __getstate__(self) -> None:
         """Prevent pickling instruments, and give a nice error message."""
         raise RuntimeError(
-            'Pickling {}. qcodes Instruments should not.'.format(self.name) +
-            ' be pickled. Likely this means you '
-            'were trying to use a local instrument (defined with '
-            'server_name=None) in a background Loop. Local instruments can '
-            'only be used in Loops with background=False.')
+            f'Error when pickling instrument {self.name}. '
+            f'QCoDeS instruments can not be pickled.')
 
     def validate_status(self, verbose: bool = False) -> None:
         """ Validate the values of all gettable parameters


Test patch:
Repository: microsoft/Qcodes

Issue:
Functionality-breaking typo in ATS9870 clock source
### Steps to reproduce
1. Under [instrument_drivers/AlazarTech/ATS9870.py](https://github.com/QCoDeS/Qcodes/blob/14bd3deb20f7d21639e463b77598aa2c1ba8edab/qcodes/instrument_drivers/AlazarTech/ATS9870.py) the clock_source parameter has a value mapping. It lists `EXTERNAL_CLOCK_10_MHz_REF` as on of the options.
2. ATS9870.py builds on [ATS.py](https://github.com/QCoDeS/Qcodes/blob/14bd3deb20f7d21639e463b77598aa2c1ba8edab/qcodes/instrument_drivers/AlazarTech/ATS.py). However, the the corresponding parameter in ATS.py is named `EXTERNAL_CLOCK_10MHz_REF` - without the underscore between 10 and MHz. See line 209. This means that setting clock source in ATS9870 currently does not work and leads to errors.

### Expected behaviour
Setting the clock source in ATS9870 to external should pass the correct parameters to self.api.set_capture_clock in ATS.py.

### Actual behaviour
Instead it does not recognize that the clock source is set to external because the if statement checks for a value that does not exist in ATS9870. This leads to sending incompatible parameters to self.api.set_capture_clock in ATS.py.

### System
**Windows 10**

**Master**

**0.20.1**



Discussion:

Resolving patch:
diff --git a/qcodes/instrument_drivers/AlazarTech/ATS9870.py b/qcodes/instrument_drivers/AlazarTech/ATS9870.py
--- a/qcodes/instrument_drivers/AlazarTech/ATS9870.py
+++ b/qcodes/instrument_drivers/AlazarTech/ATS9870.py
@@ -28,7 +28,7 @@ def __init__(self, name: str,
                            val_mapping={'INTERNAL_CLOCK': 1,
                                         'SLOW_EXTERNAL_CLOCK': 4,
                                         'EXTERNAL_CLOCK_AC': 5,
-                                        'EXTERNAL_CLOCK_10_MHz_REF': 7})
+                                        'EXTERNAL_CLOCK_10MHz_REF': 7})
 
         self.add_parameter(name='external_sample_rate',
                            get_cmd=None,


Test patch:
Repository: microsoft/Qcodes

Issue:
station.snapshot_base doesn't respect parameter.snapshot_exclude
I noticed the following behavior when directly adding parameters to a station:

```py
from qcodes import Station, Parameter

station = Station()

station.add_component(Parameter("foo", snapshot_exclude=True))

station.snapshot_base()
```
This issues a warning "foo is used in the snapshot while it should be excluded from the snapshot", and the parameter indeed appears in the snapshot even though it shouldn't.

This is a simple fix, it should just be a an additional condition [here](https://github.com/QCoDeS/Qcodes/blob/85f56f312ad1d784de72a1b816022d5a1650803c/qcodes/station.py#L184). I don't have time to write a proper PR with tests for this right now, but I can submit something later if this isn't fixed by then.


Discussion:
thank you @mgunyho ! a PR later is great :)

Resolving patch:
diff --git a/qcodes/station.py b/qcodes/station.py
--- a/qcodes/station.py
+++ b/qcodes/station.py
@@ -184,7 +184,8 @@ def snapshot_base(self, update: Optional[bool] = True,
             elif isinstance(itm, (Parameter,
                                   ManualParameter
                                   )):
-                snap['parameters'][name] = itm.snapshot(update=update)
+                if not itm.snapshot_exclude:
+                    snap['parameters'][name] = itm.snapshot(update=update)
             else:
                 snap['components'][name] = itm.snapshot(update=update)
 
@@ -209,7 +210,9 @@ def add_component(self, component: Metadatable, name: Optional[str] = None,
                 to make it unique among previously added components.
         """
         try:
-            component.snapshot(update=update_snapshot)
+            if not (isinstance(component, Parameter)
+                    and component.snapshot_exclude):
+                component.snapshot(update=update_snapshot)
         except:
             pass
         if name is None:


Test patch:
diff --git a/qcodes/tests/test_station.py b/qcodes/tests/test_station.py
--- a/qcodes/tests/test_station.py
+++ b/qcodes/tests/test_station.py
@@ -179,6 +179,9 @@ def test_snapshot():
     station.add_component(parameter)
     parameter_snapshot = parameter.snapshot()
 
+    excluded_parameter = Parameter('excluded_parameter', snapshot_exclude=True)
+    station.add_component(excluded_parameter)
+
     component = DumyPar('component')
     component.metadata['smth'] = 'in the way she moves'
     station.add_component(component)
@@ -196,6 +199,7 @@ def test_snapshot():
     assert ['instrument'] == list(snapshot['instruments'].keys())
     assert instrument_snapshot == snapshot['instruments']['instrument']
 
+    # the list should not contain the excluded parameter
     assert ['parameter'] == list(snapshot['parameters'].keys())
     assert parameter_snapshot == snapshot['parameters']['parameter']
Repository: microsoft/Qcodes

Issue:
Disable logging on import for Sphinx documentation builds
### Steps to reproduce
1. Create a project with sphinx documentation
2. Add a python notebook to your documentation
3. Import qcodes inside the python notebook.
4. Build sphinx documentation
5. > now conditional import of logging is run.

### Expected behaviour

When Qcodes is imported in a python notebook which is build by sphinx, qcodes conditionally start logging.
The function `logger.running_in_test_or_tool` is evaluated after running `logger.start_logging_on_import` raising an exception.

### Actual behaviour

The following error is raised.
```
File "d:\git\qcodes\qcodes\logger\logger.py", line 365, in conditionally_start_all_logging
    if not running_in_test_or_tool() and start_logging_on_import():
File "d:\git\qcodes\qcodes\logger\logger.py", line 339, in start_logging_on_import
    config = qc.config
AttributeError: module 'qcodes' has no attribute 'config'
```

### Additional information
Detailed discussion going on at [quantify-os](https://gitlab.com/quantify-os/quantify/-/issues/10)

### System
**operating system**
Windows / Linux

**qcodes branch**
master

**qcodes commit**
f688fe3f1f22ce72e4b0eb0ee359cd7b807f34d9



Discussion:

Resolving patch:
diff --git a/qcodes/logger/logger.py b/qcodes/logger/logger.py
--- a/qcodes/logger/logger.py
+++ b/qcodes/logger/logger.py
@@ -356,12 +356,13 @@ def running_in_test_or_tool() -> bool:
         tools = (
             'pytest.py',
             'pytest',
+            r'sphinx\__main__.py',    # Sphinx docs building
             '_jb_pytest_runner.py',  # Jetbrains Pycharm
             'testlauncher.py'        # VSCode
         )
         return any(sys.argv[0].endswith(tool) for tool in tools)
 
-    if start_logging_on_import() and not running_in_test_or_tool():
+    if not running_in_test_or_tool() and start_logging_on_import():
         start_all_logging()
 
 


Test patch:
Repository: microsoft/Qcodes

Issue:
AlazarTech ATS mode=TriggeredStreaming fails with > 1 buffer
### Steps to reproduce
1. call ats.aquire(mode='TS', samples_per_record=100e6, buffers_per_acquisition=10)
2. qcodes driver tries to allocate buffer of 1000e6 bytes, which is larger than ATS driver supports.

2nd:
1. call ats.aquire(mode='TS', samples_per_record=1e6, buffers_per_acquisition=10)
2. instead of 10 time handle_buffer with a buffer of 1e6 bytes the qcodes driver returns a buffer with 10e6 bytes.

See fix in pull request.

**qcodes branch**
Master

**qcodes commit**



Discussion:

Resolving patch:
diff --git a/qcodes/instrument_drivers/AlazarTech/ATS.py b/qcodes/instrument_drivers/AlazarTech/ATS.py
--- a/qcodes/instrument_drivers/AlazarTech/ATS.py
+++ b/qcodes/instrument_drivers/AlazarTech/ATS.py
@@ -386,6 +386,10 @@ def acquire(
         internal_buffer_size_requested = (bits_per_sample * samples_per_record *
                                           records_per_buffer) // 8
 
+        if mode == 'TS':
+            transfer_buffer_size //= buffers_per_acquisition
+            internal_buffer_size_requested //= buffers_per_acquisition
+
         if internal_buffer_size_requested > max_buffer_size:
             raise RuntimeError(f"Requested a buffer of size: "
                                f"{internal_buffer_size_requested / 1024 ** 2}"


Test patch:
Repository: microsoft/Qcodes

Issue:
Setting R&S ZNB npts fails in CW mode
### Steps to reproduce
1. Load R&S ZNB driver
2. set it to CW mode
3. try to change the `npts` parameter

MWE:

```py
import qcodes as qc
import qcodes.instrument_drivers.rohde_schwarz.ZNB as ZNB

qc.Instrument.close_all()

station = qc.Station()

station.add_component(ZNB.ZNB('VNA', ..., init_s_params=False))
station.VNA.add_channel('S21')

vna = station.VNA


# this works fine
vna.S21.npts(123)
print(vna.S21.npts())


# this causes a timeout error
vna.S21.setup_cw_sweep()
vna.S21.npts(201)
print(vna.S21.npts())


# this works again
vna.S21.setup_lin_sweep()
vna.S21.npts(345)
print(vna.S21.npts())
```

### Expected behaviour
The `npts` parameter should be set correctly.

### Actual behaviour
I get the exception:
```
VisaIOError: ('VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.', "asking 'SENS1:FREQ:START?' to <ZNB: VNA>", 'getting VNA_S21_start', 'setting VNA_S21_npts to 201')
```

The problem seems to be that setting `npts` calls `self.update_lin_traces()` which in turn calls `self.start.get()` which doesn't seem to work if the VNA is in CW mode.

### System
**operating system**
Windows 7

**qcodes branch**
`v0.26.0`


Discussion:
@mgunyho Thanks for the detailed description. It looks like perhaps update_lin_traces should only be called if the instrument is in a different mode. Would you be willing to make a pull request that implements this ? 
Yes, that seems to be the correct fix. I can try to implement it the next time we're using the VNA.

Resolving patch:
diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py
--- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py
+++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py
@@ -654,8 +654,10 @@ def _set_stop(self, val: float) -> None:
     def _set_npts(self, val: int) -> None:
         channel = self._instrument_channel
         self.write(f"SENS{channel}:SWE:POIN {val:.7f}")
-        self.update_lin_traces()
-        self.update_cw_traces()
+        if self.sweep_type().startswith("CW"):
+            self.update_cw_traces()
+        else:
+            self.update_lin_traces()
 
     def _set_bandwidth(self, val: int) -> None:
         channel = self._instrument_channel


Test patch:
Repository: microsoft/Qcodes

Issue:
Incorrect baud rate in QDevil QDAC drivers
Our colleagues and I from the IBM Research Europe - Zurich lab have found the baud rate in QDevid QDAC drivers to be incorrect.

## Incorrect baud rate in QDevil QDAC drivers

### Steps to reproduce
1. In the file "qcodes/instrument_drivers/QDev/QDac_channels.py", at line 200, the `handle.baud_rate = 480600` is incorrect.
2. In the file "qcodes/instrument_drivers/QDevil/QDevil_QDAC.py", at line 240, the `handle.baud_rate = 480600` is incorrect.

### Expected behaviour
From our QDAC manual sheet 14(51), we can read 

> [...] select a baud rate of 460800 [...]

### Actual behaviour
The numbers 6 and 8 are inverted. We don't see errors often due to this, but it should be corrected nevertheless.

If you are using a released version of qcodes (recommended):
**qcodes version**: 0.32



Discussion:

Resolving patch:
diff --git a/qcodes/instrument_drivers/QDev/QDac_channels.py b/qcodes/instrument_drivers/QDev/QDac_channels.py
--- a/qcodes/instrument_drivers/QDev/QDac_channels.py
+++ b/qcodes/instrument_drivers/QDev/QDac_channels.py
@@ -197,7 +197,7 @@ def __init__(self,
         self._get_status_performed = False
         # This is the baud rate on power-up. It can be changed later but
         # you must start out with this value.
-        handle.baud_rate = 480600
+        handle.baud_rate = 460800
         handle.parity = visa.constants.Parity(0)
         handle.data_bits = 8
         self.set_terminator('\n')
diff --git a/qcodes/instrument_drivers/QDevil/QDevil_QDAC.py b/qcodes/instrument_drivers/QDevil/QDevil_QDAC.py
--- a/qcodes/instrument_drivers/QDevil/QDevil_QDAC.py
+++ b/qcodes/instrument_drivers/QDevil/QDevil_QDAC.py
@@ -237,7 +237,7 @@ def __init__(self,
 
         assert isinstance(handle, SerialInstrument)
         # Communication setup + firmware check
-        handle.baud_rate = 480600
+        handle.baud_rate = 460800
         handle.parity = visa.constants.Parity(0)
         handle.data_bits = 8
         self.set_terminator('\n')


Test patch:
Repository: microsoft/Qcodes

Issue:
HDF5 error with 'slow' acquisition of 2D array
## Steps to reproduce:
import qcodes as qc

from qcodes.data import hdf5_format
from qcodes.data.data_set import DataSet

from qcodes.tests.instrument_mocks import MockParabola

DataSet.default_formatter = hdf5_format.HDF5Format()

mockParabola = MockParabola(name='MockParabola')

loop = qc.Loop(mockParabola.x[-100:100:1], delay=0.1).loop(
    mockParabola.y[-100:100:1]).each(mockParabola.x)
loop.run(name='test_hdf5')

## Exception:

  File "c:\projects\sldesnoo.qcodes\qcodes\data\hdf5_format.py", line 243, in write
    new_data_shape)

ValueError: cannot reshape array of size 40000 into shape (7801,1)

## Proposed fix:

Added .flat on line 243:
            dset[old_dlen:new_dlen] = x.flat[old_dlen:new_dlen].reshape(
                new_data_shape)

HDF5 error with 'slow' acquisition of 2D array
## Steps to reproduce:
import qcodes as qc

from qcodes.data import hdf5_format
from qcodes.data.data_set import DataSet

from qcodes.tests.instrument_mocks import MockParabola

DataSet.default_formatter = hdf5_format.HDF5Format()

mockParabola = MockParabola(name='MockParabola')

loop = qc.Loop(mockParabola.x[-100:100:1], delay=0.1).loop(
    mockParabola.y[-100:100:1]).each(mockParabola.x)
loop.run(name='test_hdf5')

## Exception:

  File "c:\projects\sldesnoo.qcodes\qcodes\data\hdf5_format.py", line 243, in write
    new_data_shape)

ValueError: cannot reshape array of size 40000 into shape (7801,1)

## Proposed fix:

Added .flat on line 243:
            dset[old_dlen:new_dlen] = x.flat[old_dlen:new_dlen].reshape(
                new_data_shape)



Discussion:

Resolving patch:
diff --git a/qcodes/data/hdf5_format.py b/qcodes/data/hdf5_format.py
--- a/qcodes/data/hdf5_format.py
+++ b/qcodes/data/hdf5_format.py
@@ -239,8 +239,7 @@ def write(self, data_set, io_manager=None, location=None,
                                 datasetshape[1])
             dset.resize(new_datasetshape)
             new_data_shape = (new_dlen - old_dlen, datasetshape[1])
-            dset[old_dlen:new_dlen] = x[old_dlen:new_dlen].reshape(
-                new_data_shape)
+            dset[old_dlen:new_dlen] = x.flat[old_dlen:new_dlen].reshape(new_data_shape)
             # allow resizing extracted data, here so it gets written for
             # incremental writes aswell
             dset.attrs['shape'] = x.shape


Test patch:
Repository: microsoft/Qcodes

Issue:
Keithley6500 does not set mode correctly
###
The Keithley6500 driver does not set the mode correctly.

### Steps to reproduce
```python
from qcodes.instrument_drivers.tektronix.Keithley_6500 import Keithley_6500
keithley_1 = Keithley_6500("keithley_1", address="TCPIP0::192.168.2.105::inst0::INSTR")
keithley_1.mode('dc voltage')
```

### Expected behaviour
The mode on the instrument to be set to DC voltage

### Actual behaviour
The instrument shows a message on the front panel that the parameter value should be specified as a string. In Python, the commands are executed without exception.

### System
Windows 10

If you are using a released version of qcodes (recommended):
0.31.0

###
Following the manual:
https://download.tek.com/manual/DMM6500-901-01B_Sept_2019_Ref.pdf
the solution is simply to add quotes around the mode value in the command. 

Related to #1541

I will add a PR shortly.


Discussion:

Resolving patch:
diff --git a/qcodes/instrument_drivers/tektronix/Keithley_6500.py b/qcodes/instrument_drivers/tektronix/Keithley_6500.py
--- a/qcodes/instrument_drivers/tektronix/Keithley_6500.py
+++ b/qcodes/instrument_drivers/tektronix/Keithley_6500.py
@@ -1,6 +1,5 @@
-from typing import Any, TypeVar, Callable
 from functools import partial
-from typing import Union
+from typing import Any, Callable, TypeVar, Union
 
 from qcodes import VisaInstrument
 from qcodes.utils.validators import Bool, Enum, Ints, MultiType, Numbers
@@ -78,10 +77,12 @@ def __init__(
                           'dc voltage': 'VOLT:DC', '2w resistance': 'RES', '4w resistance': 'FRES',
                           'temperature': 'TEMP', 'frequency': 'FREQ'}
 
-        self.add_parameter('mode',
-                           get_cmd='SENS:FUNC?',
-                           set_cmd="SENS:FUNC {}",
-                           val_mapping=self._mode_map)
+        self.add_parameter(
+            "mode",
+            get_cmd="SENS:FUNC?",
+            set_cmd="SENS:FUNC '{}'",
+            val_mapping=self._mode_map,
+        )
 
         self.add_parameter('nplc',
                            get_cmd=partial(


Test patch:
Repository: microsoft/Qcodes

Issue:
Integrate changelogs with sphinx-isssue
It would be nice if our changelogs had links to the prs that they are coming from. Sphinx issue seems like a good way that could be done https://pypi.org/project/sphinx-issues/


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -58,6 +58,7 @@
     "qcodes.sphinx_extensions.parse_parameter_attr",
     "sphinxcontrib.towncrier",
     "autodocsumm",
+    "sphinx_issues",
 ]
 
 # include special __xxx__ that DO have a docstring
@@ -443,3 +444,5 @@
 towncrier_draft_autoversion_mode = "draft"
 towncrier_draft_include_empty = True
 towncrier_draft_working_directory = ".."
+
+issues_github_path = "QCoDeS/Qcodes"


Test patch:
Repository: microsoft/Qcodes

Issue:
Filename collision due to case-sensitivity in Keysight folder
When pulling the qcodes repository on Windows, there is a filename collision between the uppercase and lowercase Keysight folders.

The error message is as follows:
```bash
$ git clone https://github.com/QCoDeS/Qcodes.git
Cloning into 'Qcodes'...
remote: Enumerating objects: 1522, done.
remote: Counting objects: 100% (1522/1522), done.
remote: Compressing objects: 100% (655/655), done.

Receiving objects: 100% (112398/112398), 242.65 MiB | 2.58 MiB/s, done.
Resolving deltas: 100% (87395/87395), done.
warning: the following paths have collided (e.g. case-sensitive paths
on a case-insensitive filesystem) and only one from the same
colliding group is in the working tree:

  'qcodes/instrument_drivers/Keysight/__init__.py'
  'qcodes/instrument_drivers/keysight/__init__.py'
```

I propose we remove the lowercase keysight folder as it has now been deprecated for over 2 years.

### System
Windows/OSX and other OS's with case insensitive file systems.


Discussion:
i'm working on macOS and haven't seen this problem. But i'm all for removing that lowercase directory if it is possible in a clean way.
@astafan8 Please see the discussion of the issues in #1710 
@jenshnielsen thanks, already curiously following it :)

Resolving patch:
diff --git a/qcodes/instrument_drivers/Keysight/__init__.py b/qcodes/instrument_drivers/Keysight/__init__.py
--- a/qcodes/instrument_drivers/Keysight/__init__.py
+++ b/qcodes/instrument_drivers/Keysight/__init__.py
@@ -0,0 +1 @@
+# Intentionally left blank
diff --git a/qcodes/instrument_drivers/keysight/__init__.py b/qcodes/instrument_drivers/keysight/__init__.py
deleted file mode 100644


Test patch:
Repository: microsoft/Qcodes

Issue:
Add a favicon to the qcodes docs
There is a nice sphinx extension here that enables this https://pypi.org/project/sphinx-favicon/ and QCoDeS already has a suitable logo. 
What is needed is to move that logo to the `_static` dir and enable the extension and check that this logo has a resonable size


Discussion:
I'll take this!

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -59,6 +59,7 @@
     "sphinxcontrib.towncrier",
     "autodocsumm",
     "sphinx_issues",
+    "sphinx-favicon",
 ]
 
 # include special __xxx__ that DO have a docstring
@@ -219,6 +220,10 @@
 # so a file named "default.css" will overwrite the builtin "default.css".
 html_static_path = ['_static']
 
+# Add custom favicon to the sphinx html documentation.
+# Can be an absolute url or a local static file.
+favicons = {"rel": "icon", "static-file": "qcodes_favicon.png", "type": "image/png"}
+
 # Add any extra paths that contain custom files (such as robots.txt or
 # .htaccess) here, relative to this directory. These files are copied
 # directly to the root of the documentation.


Test patch: