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

Issue:
Remove Python 3.5 support
Python 3.5 has reached [end-of-life](https://www.python.org/downloads/release/python-3510/) a month ago. It would be awesome to be able to use 3.6 features like [f-strings](https://docs.python.org/3.6/whatsnew/3.6.html#pep-498-formatted-string-literals) in our codebase. People are actually using this in PRs that get submitted (e.g. #324). 
I propose removing 3.5 support. @cjermain @CasperSchippers thoughts?


Discussion:
I would agree that dropping support for 3.5 would be fine now it has reached end-of-life. 

Resolving patch:
diff --git a/pymeasure/instruments/ni/__init__.py b/pymeasure/instruments/ni/__init__.py
--- a/pymeasure/instruments/ni/__init__.py
+++ b/pymeasure/instruments/ni/__init__.py
@@ -32,6 +32,6 @@
     from .virtualbench import VirtualBench
     # direct access to armstrap/pyvirtualbench wrapper:
     # from .virtualbench import VirtualBench_Direct
-except ImportError:  # when we drop python 3.5 support, we can use ModuleNotFoundError
+except ModuleNotFoundError:
     # Error Logging is handled within package
     pass
diff --git a/pymeasure/instruments/ni/virtualbench.py b/pymeasure/instruments/ni/virtualbench.py
--- a/pymeasure/instruments/ni/virtualbench.py
+++ b/pymeasure/instruments/ni/virtualbench.py
@@ -48,8 +48,7 @@
     # Requires 'pyvirtualbench' package:
     # https://github.com/armstrap/armstrap-pyvirtualbench
     import pyvirtualbench as pyvb
-except ImportError as err:  # when we drop python 3.5 support, we can use ModuleNotFoundError
-    # catch here for logging
+except ModuleNotFoundError as err:
     log.info('Failed loading the pyvirtualbench package. '
              + 'Check the NI VirtualBench documentation on how to '
              + 'install this external dependency. '
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -67,7 +67,6 @@
         "Operating System :: POSIX",
         "Operating System :: Unix",
         "Programming Language :: Python :: 3 :: Only",
-        "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",


Test patch:
Repository: pymeasure/pymeasure

Issue:
Python 3.9 compatibility
Python 3.9 [is out](https://docs.python.org/3.9/whatsnew/3.9.html). We should ensure that we are compatible, so there are a couple of things to do

* [x] Create a fresh Python 3.9 environment.yml (with current package versions)
* [x] Update Travis and Appveyor CI setup files
  - [x] Check if the Appveyor 3.8 build can use the 3.8 miniconda, not 3.7, now
  - [x] I think we should relax the python version specifiers in the environment.yml to major.minor (i.e. python 3.8, not 3.8.1), to also get python bugfixes, even though it's a bit less strict in CI version stability.
  - [x] Check if we should bump Trais ubuntu version to the current LTS focal (20.04)
* The conda-forge package is repackaged automatically, apparently - it's already available.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -70,6 +70,7 @@
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
+        "Programming Language :: Python :: 3.9",
         "Topic :: Scientific/Engineering",
     ],
     keywords="measure instrument experiment control automate graph plot"


Test patch:
Repository: pymeasure/pymeasure

Issue:
Consider using GitHub Actions over Appveyor/TravisCI.
Travis jobs take a long time to complete, and we use 2 different services (appveyor and travis) for CI. Github now offers Actions, which could unify and simplify our CI setup.

Current GH action usage limits seem very reasonable: https://docs.github.com/en/free-pro-team@latest/actions/reference/usage-limits-billing-and-administration#usage-limits


Discussion:

Resolving patch:
diff --git a/pymeasure/instruments/agilent/agilent4156.py b/pymeasure/instruments/agilent/agilent4156.py
--- a/pymeasure/instruments/agilent/agilent4156.py
+++ b/pymeasure/instruments/agilent/agilent4156.py
@@ -532,7 +532,7 @@ def compliance(self):
         """ This command sets the *constant* compliance value of SMU<n>. If the SMU channel is setup as a variable (VAR1, VAR2, VARD) then compliance limits are set by the variable definition.
 
         - Value: Voltage in (-200V, 200V) and current in (-1A, 1A) based
-        on :meth:`~.SMU.channel_mode`.
+          on :meth:`~.SMU.channel_mode`.
 
         .. code-block:: python
 
diff --git a/pymeasure/instruments/keithley/keithley2700.py b/pymeasure/instruments/keithley/keithley2700.py
--- a/pymeasure/instruments/keithley/keithley2700.py
+++ b/pymeasure/instruments/keithley/keithley2700.py
@@ -180,7 +180,7 @@ def determine_valid_channels(self):
     def close_rows_to_columns(self, rows, columns, slot=None):
         """ Closes (connects) the channels between column(s) and row(s)
         of the 7709 connection matrix.
-        Only one of the parameters `rows' or 'columns' can be "all"
+        Only one of the parameters 'rows' or 'columns' can be "all"
 
         :param rows: row number or list of numbers; can also be "all"
         :param columns: column number or list of numbers; can also be "all"
@@ -193,7 +193,7 @@ def close_rows_to_columns(self, rows, columns, slot=None):
     def open_rows_to_columns(self, rows, columns, slot=None):
         """ Opens (disconnects) the channels between column(s) and row(s)
         of the 7709 connection matrix.
-        Only one of the parameters `rows' or 'columns' can be "all"
+        Only one of the parameters 'rows' or 'columns' can be "all"
 
         :param rows: row number or list of numbers; can also be "all"
         :param columns: column number or list of numbers; can also be "all"
@@ -206,7 +206,7 @@ def open_rows_to_columns(self, rows, columns, slot=None):
     def channels_from_rows_columns(self, rows, columns, slot=None):
         """ Determine the channel numbers between column(s) and row(s) of the
         7709 connection matrix. Returns a list of channel numbers.
-        Only one of the parameters `rows' or 'columns' can be "all"
+        Only one of the parameters 'rows' or 'columns' can be "all"
 
         :param rows: row number or list of numbers; can also be "all"
         :param columns: column number or list of numbers; can also be "all"


Test patch:
Repository: pymeasure/pymeasure

Issue:
Pyvisa no longer support ask, replace with query
In resources.py
`idn = res.ask('*idn?')[:-1]`
Should be:
`idn = res.query('*idn?')[:-1]`


Discussion:
These changes seem to have been introduced with PyVisa 1.11 in Sept of 2020..

> PyVisa 1.11 also removes deprecated functions and attributes that were supposed
> to be removed  in 1.10:
> 
> - `ask`: use `query` instead
> - `ask_delay`: use `query_delay`
> - `ask_for_values`: use either `query_ascii_values` or `query_binary_values` as relevant
> - `write_values`: use either `write_ascii_values` or `write_binary_values` as relevant
> - `read_values`: use either `read_ascii_values` or `read_binary_values` as relevant
> - `query_values`: use either `query_ascii_values` or `query_binary_values` as relevant
> - `values_format`: has no equivalent simply pass the proper argument to either
>   the ascii or binary variant of the function (`read_xxxx_values`, `write_xxxx_values`,
>   `query_xxxx_values`)

https://github.com/pyvisa/pyvisa/blob/bc07e6b5b17e98eeed29cc7b196f3f4ac25e077f/CHANGES#L38
Well spotted, thank you! We already fixed this previously, but we have overlooked this occurrence. Are you up for [submitting a PR](https://pymeasure.readthedocs.io/en/latest/dev/contribute.html) with this small fix?

Resolving patch:
diff --git a/pymeasure/instruments/resources.py b/pymeasure/instruments/resources.py
--- a/pymeasure/instruments/resources.py
+++ b/pymeasure/instruments/resources.py
@@ -47,7 +47,7 @@ def list_resources():
             # try to avoid errors from *idn?
             try:
                 # noinspection PyUnresolvedReferences
-                idn = res.ask('*idn?')[:-1]
+                idn = res.query('*idn?')[:-1]
             except pyvisa.Error:
                 idn = "Not known"
             finally:


Test patch:
Repository: pymeasure/pymeasure

Issue:
report code error found within Instrument.py, while Measuring with Keithley 6517B Electrometer
This is the basic code

`pAmeter=Keithley6517B('ASRL6::INSTR')
id=pAmeter.id
print(id)
#pAmeter.reset()
df=pAmeter.measure_current(0.1,1.05e-11)
sleep(0.1)
a=pAmeter.current
print(a)`

Type error see below:

> KEITHLEY INSTRUMENTS INC.,MODEL 6517B,4402161,A13/700x
Traceback (most recent call last):
  File "path\to\file/pAmeter_6517B_test.py", line 24, in <module>
    a=pAmeter.current
  File "path\to\python\lib\site-packages\pymeasure\instruments\instrument.py", line 233, in fget
    return get_process(vals)
TypeError: extract_value() missing 1 required positional argument: 'result'

Correction
###  in instrument.py line 233, 
the return of method fget() should be:
`return get_process(self,vals)`  instead of `return get_process(vals)`

I hope this issure will be fixed soon^OO^



Discussion:
Thanks for reporting this issue.
I think that the solution you propose is not the best one: passing self will work in this case indeed, but for most other cases (e.g. when the `get_process` is provided as a lambda function) this will cause issues.
An easier solution I think would be to turn `extract_value` into a `staticmethod`, so it won't need passing `self`.

Resolving patch:
diff --git a/pymeasure/instruments/keithley/keithley6517b.py b/pymeasure/instruments/keithley/keithley6517b.py
--- a/pymeasure/instruments/keithley/keithley6517b.py
+++ b/pymeasure/instruments/keithley/keithley6517b.py
@@ -66,7 +66,8 @@ class Keithley6517B(Instrument, KeithleyBuffer):
         cast=bool
     )
 
-    def extract_value(self, result):
+    @staticmethod
+    def extract_value(result):
         """ extracts the physical value from a result object returned
             by the instrument """
         m = re.fullmatch(r'([+\-0-9E.]+)[A-Z]{4}', result[0])


Test patch:
Repository: pymeasure/pymeasure

Issue:
How to include Channels in API documentation
In #819 I encountered the question, how to include the Channel best into the documentation.
It does not seem right, to put the channel in the same level as the instruments of that manufacturer.
Any ideas?


Discussion:
I found it: Just import the channel into the api documentation. As an example see https://pymeasure.readthedocs.io/en/latest/api/instruments/siglenttechnologies/siglent_spdbase.html

Nevertheless: This should be mentioned in the "adding instruments" section.

Resolving patch:
diff --git a/pymeasure/instruments/siglenttechnologies/siglent_spdbase.py b/pymeasure/instruments/siglenttechnologies/siglent_spdbase.py
--- a/pymeasure/instruments/siglenttechnologies/siglent_spdbase.py
+++ b/pymeasure/instruments/siglenttechnologies/siglent_spdbase.py
@@ -157,6 +157,8 @@ def configure_timer(self, step, voltage, current, duration):
 
 class SPDBase(Instrument):
     """ The base class for Siglent SPDxxxxX instruments.
+
+    Uses :class:`SPDChannel` for measurement channels.
     """
 
     def __init__(self, adapter, **kwargs):


Test patch:
Repository: pymeasure/pymeasure

Issue:
Implement `flush_read_buffer()` for `SerialAdapter`
Title says it all, there is a clear usage: https://pymeasure.readthedocs.io/en/latest/api/adapters.html?#pymeasure.adapters.VISAAdapter.flush_read_buffer

This would allow instruments to be more agnostic of the used adapter.

(Forgive me for the spike of issue reports today.)


Discussion:

Resolving patch:
diff --git a/pymeasure/adapters/adapter.py b/pymeasure/adapters/adapter.py
--- a/pymeasure/adapters/adapter.py
+++ b/pymeasure/adapters/adapter.py
@@ -141,6 +141,10 @@ def _read_bytes(self, count, break_on_termchar, **kwargs):
         """Read bytes from the instrument. Implement in subclass."""
         raise NotImplementedError("Adapter class has not implemented reading bytes.")
 
+    def flush_read_buffer(self):
+        """Flush and discard the input buffer. Implement in subclass."""
+        raise NotImplementedError("Adapter class has not implemented input flush.")
+
     # Deprecated methods.
     def ask(self, command):
         """ Write the command to the instrument and returns the resulting
diff --git a/pymeasure/adapters/serial.py b/pymeasure/adapters/serial.py
--- a/pymeasure/adapters/serial.py
+++ b/pymeasure/adapters/serial.py
@@ -107,5 +107,9 @@ def _read_bytes(self, count, break_on_termchar, **kwargs):
             # At -1 we read a very large number of bytes, which can be considered the whole buffer.
             return self.connection.read(1e99 if count == -1 else count, **kwargs)
 
+    def flush_read_buffer(self):
+        """Flush and discard the input buffer."""
+        self.connection.reset_input_buffer()
+
     def __repr__(self):
         return "<SerialAdapter(port='%s')>" % self.connection.port


Test patch:
Repository: pymeasure/pymeasure

Issue:
recent changes break MKS937B check_set_errors
It was previously ok that `check_errors` returns `None` (or nothing) as for example in [MKS937B](https://github.com/pymeasure/pymeasure/blob/68f5487b0837e9f3c5debd144a7ddfeb7bddf3e5/pymeasure/instruments/mksinst/mks937b.py#L150).

Recently it got mandatory that the `check_set_errors` and `check_get_errors` return lists. This is correctly documented and some existing devices were also changed -> 1214d32.
`MKS937B` it seems was overlooked. 

https://github.com/pymeasure/pymeasure/blob/68f5487b0837e9f3c5debd144a7ddfeb7bddf3e5/pymeasure/instruments/mksinst/mks937b.py#L150-L162

Is the only change needed here to return an empty list upon no error?



Discussion:
> Is the only change needed here to return an empty list upon no error?

yes

Thanks for raising the issue.

Resolving patch:
diff --git a/pymeasure/instruments/mksinst/mks937b.py b/pymeasure/instruments/mksinst/mks937b.py
--- a/pymeasure/instruments/mksinst/mks937b.py
+++ b/pymeasure/instruments/mksinst/mks937b.py
@@ -155,7 +155,8 @@ def check_set_errors(self):
         reply = self._re_response.search(ret)
         if reply:
             if reply.group('ack') == 'ACK':
-                return
+                self._check_extra_termination()
+                return []
         # no valid acknowledgement message found
         raise ValueError(f"invalid reply '{ret}' found in check_errors")
 


Test patch:
diff --git a/tests/instruments/mksinst/test_mks937b.py b/tests/instruments/mksinst/test_mks937b.py
--- a/tests/instruments/mksinst/test_mks937b.py
+++ b/tests/instruments/mksinst/test_mks937b.py
@@ -57,8 +57,18 @@ def test_ion_gauge_status_invalid_channel():
             inst.ch_2.ion_gauge_status
 
 
-def test_unit():
-    """Verify the communication of the voltage getter."""
+def test_unit_setter():
+    """Verify the communication of the unit setter."""
+    with expected_protocol(
+        MKS937B,
+        [("@253U!TORR", "@253ACKTORR"),
+         (None, b"FF")],
+    ) as inst:
+        inst.unit = "Torr"
+
+
+def test_unit_getter():
+    """Verify the communication of the unit getter."""
     with expected_protocol(
         MKS937B,
         [("@253U?", "@253ACKTORR"),
@@ -68,7 +78,7 @@ def test_unit():
 
 
 def test_power_enabled():
-    """Verify the communication of the voltage getter."""
+    """Verify the communication of the channel power getter."""
     with expected_protocol(
         MKS937B,
         [("@253CP1?", "@253ACKON"),
Repository: pymeasure/pymeasure

Issue:
expected_protocol uses empty dictionary as default value
`expected_protocol` uses an empty dictionary as a default value, which is bad practice.
The underlying `ProtocolAdapter` already accepts `None`, so a change to `None` is a no brainer.


Discussion:

Resolving patch:
diff --git a/pymeasure/instruments/agilent/agilentB1500.py b/pymeasure/instruments/agilent/agilentB1500.py
--- a/pymeasure/instruments/agilent/agilentB1500.py
+++ b/pymeasure/instruments/agilent/agilentB1500.py
@@ -277,7 +277,7 @@ class _data_formatting_generic():
         smu_status = {
             1: 'A/D converter overflowed.',
             2: 'Oscillation of force or saturation current.',
-            4: 'Antoher unit reached its compliance setting.',
+            4: 'Another unit reached its compliance setting.',
             8: 'This unit reached its compliance setting.',
             16: 'Target value was not found within the search range.',
             32: 'Search measurement was automatically stopped.',
diff --git a/pymeasure/instruments/hcp/tc038.py b/pymeasure/instruments/hcp/tc038.py
--- a/pymeasure/instruments/hcp/tc038.py
+++ b/pymeasure/instruments/hcp/tc038.py
@@ -161,6 +161,6 @@ def set_monitored_quantity(self, quantity='temperature'):
 
     information = Instrument.measurement(
         "INF6",
-        """Get the information about the device and its capabilites.""",
+        """Get the information about the device and its capabilities.""",
         get_process=lambda got: got[7:-1],
     )


Test patch:
diff --git a/pymeasure/test.py b/pymeasure/test.py
--- a/pymeasure/test.py
+++ b/pymeasure/test.py
@@ -29,7 +29,7 @@
 
 @contextmanager
 def expected_protocol(instrument_cls, comm_pairs,
-                      connection_attributes={}, connection_methods={},
+                      connection_attributes=None, connection_methods=None,
                       **kwargs):
     """Context manager that checks sent/received instrument commands without a
     device connected.
Repository: nilearn/nilearn

Issue:
Missing brackets
An error occurs in the downloader when trying to fetch a dataset : the function _join_ used to build the URLs takes its parameters in one array whereas several parameters are given in the code.



Discussion:

Resolving patch:
diff --git a/nisl/datasets.py b/nisl/datasets.py
--- a/nisl/datasets.py
+++ b/nisl/datasets.py
@@ -350,8 +350,8 @@ def fetch_star_plus(data_dir=None):
         url1 = 'http://www.cs.cmu.edu/afs/cs.cmu.edu/project/theo-81/www/'
         url2 = 'http://www.cs.cmu.edu/afs/cs.cmu.edu/project/theo-83/www/'
 
-        url1_files = ["/".join(url1, i) for i in file_names[0:3]]
-        url2_files = ["/".join(url2, i) for i in file_names[3:6]]
+        url1_files = ["/".join([url1, i]) for i in file_names[0:3]]
+        url2_files = ["/".join([url2, i]) for i in file_names[3:6]]
         urls = url1_files + url2_files
 
         full_names = _fetch_dataset('starplus', urls, data_dir=data_dir)
@@ -551,7 +551,7 @@ def _fetch_kamitani(data_dir=None):
     except IOError:
         url = ''
         tar_name = 'public_beta_20100515.zip'
-        urls = ['/'.join(url, tar_name)]
+        urls = ["/".join([url, tar_name])]
         _fetch_dataset('kamitani', urls, data_dir=data_dir)
         files = _get_dataset("kamitani", file_names, data_dir=data_dir)
 
@@ -675,7 +675,7 @@ def fetch_nyu_rest(n_subjects=None, data_dir=None):
     try:
         files = _get_dataset("nyu_rest", file_names, data_dir=data_dir)
     except IOError:
-        url = 'http://www.nitrc.org/frs/download.php/'
+        url = 'http://www.nitrc.org/frs/download.php'
         tar_prefixes = ['1071']
         tar_names = ['NYU_TRT_session1a.tar.gz']
         """
@@ -685,9 +685,9 @@ def fetch_nyu_rest(n_subjects=None, data_dir=None):
             'NYU_TRT_session2b.tar.gz', 'NYU_TRT_session3a.tar.gz',
             'NYU_TRT_session3b.tar.gz']
         """
-        tar_full_names = [os.path.join(prefix, name)
+        tar_full_names = ["/".join([prefix, name])
                           for prefix, name in zip(tar_prefixes, tar_names)]
-        urls = ['/'.join(url, name) for name in tar_full_names]
+        urls = ["/".join([url, name]) for name in tar_full_names]
         _fetch_dataset('nyu_rest', urls, data_dir=data_dir)
         files = _get_dataset("nyu_rest", file_names, data_dir=data_dir)
 


Test patch:
Repository: nilearn/nilearn

Issue:
Numpy 1.4 required
In plot_haxby_decoding.py, numpy.in1d is called. This function has been added to numpy 1.4.0 but numpy >= 1.3.0 is required for the scikit-learn. Should we require numpy 1.4.0 ?

Related numpy man page : http://docs.scipy.org/doc/numpy/reference/generated/numpy.in1d.html

``` python
Traceback (most recent call last):
  File "plot_haxby_decoding.py", line 44, in <module>
    condition_mask = np.in1d(conditions, ('face', 'house'))
AttributeError: 'module' object has no attribute 'in1d'
```



Discussion:
> In plot_haxby_decoding.py, numpy.in1d is called. This function has been added to numpy 1.4.0 but numpy >= 1.3.0 is required for the scikit-learn.

Good catch!

> Should we require numpy 1.4.0 ?

No. We need to find a workaroud, for instance using np.logical_or on the
two conditions.

Can you take care of this?

I'll take a look after lunch time.

> I'll take a look after lunch time.

OK, I'll probably be off-line till late tonight by then.


Resolving patch:
diff --git a/plot_haxby_decoding.py b/plot_haxby_decoding.py
--- a/plot_haxby_decoding.py
+++ b/plot_haxby_decoding.py
@@ -41,7 +41,7 @@
 ### Restrict to faces and houses ##############################################
 
 # Keep only data corresponding to face or houses
-condition_mask = np.in1d(conditions, ('face', 'house'))
+condition_mask = np.array([item in ('face', 'house') for item in conditions])
 X = X[condition_mask]
 y = y[condition_mask]
 session = session[condition_mask]


Test patch:
Repository: nilearn/nilearn

Issue:
The upper colorbar does not display well when using subplots
See the code below:

``` python

import nibabel
import matplotlib.pyplot as plt
from nilearn import datasets
from nilearn.plotting import plot_stat_map
dataset_files = datasets.fetch_localizer_calculation_task(n_subjects=1)
img = nibabel.load(dataset_files['cmaps'][0])
plt.figure()
for i in range(2):
    ax = plt.subplot(2, 1, i + 1)
    plot_stat_map(img, axes=ax)
plt.show()
```

![figure](https://cloud.githubusercontent.com/assets/1680079/5259446/87eff726-7a00-11e4-93a2-abca8d838a19.png)



Discussion:
Seems that the top border of the figure is cut when plotting, this is what I got inline using the same code (on another map).

![subplots](https://cloud.githubusercontent.com/assets/8612476/5260642/645ced12-7a11-11e4-867d-a51378f5e01e.png)


Resolving patch:
diff --git a/nilearn/plotting/slicers.py b/nilearn/plotting/slicers.py
--- a/nilearn/plotting/slicers.py
+++ b/nilearn/plotting/slicers.py
@@ -407,15 +407,18 @@ def _map_show(self, img, type='imshow', **kwargs):
         return ims
 
     def _colorbar_show(self, im):
-        adjusted_width = self._colorbar_width / len(self.axes)
-        adjusted_right_margin = 0.01 / len(self.axes)
+        x_adjusted_width = self._colorbar_width / len(self.axes)
+        x_adjusted_right_margin = 0.01 / len(self.axes)
         figure = self.frame_axes.figure
         _, y0, x1, y1 = self.rect
+        y_width = y1 - y0
+        y_margin = 0.05 * y_width
+
         self._colorbar_ax = figure.add_axes([
-            x1 - (adjusted_width + adjusted_right_margin),
-            y0 + 0.05,
-            adjusted_width - adjusted_right_margin,
-            y1 - 0.10])
+            x1 - (x_adjusted_width + x_adjusted_right_margin),
+            y0 + y_margin,
+            x_adjusted_width - x_adjusted_right_margin,
+            y_width - 2 * y_margin])
 
         ticks = np.linspace(im.norm.vmin, im.norm.vmax, 5)
         figure.colorbar(im, cax=self._colorbar_ax, ticks=ticks)


Test patch: