Repository: pyqtgraph/pyqtgraph

Issue:
TypeError in PlotCurveItem.py: arguments did not match any overloaded call
<!-- In the following, please describe your issue in detail! -->
<!-- If some sections do not apply, just remove them. -->

### Short description

With version 0.13.1 in conda, we see a repeated exception in one of our pyqtgraph applications, and the X axis doesn't draw.  It's unclear from the exception if there's a problem with our code or not, the exception appears to be entirely within the pyqtgraph package.

### Expected behavior

X axis draws normally

### Real behavior

```
/home/jrollins/.conda/envs/igwn/lib/python3.9/site-packages/pyqtgraph/debug.py:128: RuntimeWarning: Ignored exception:
Traceback (most recent call last):
  File "/home/jrollins/.conda/envs/igwn/bin/ndscope", line 10, in <module>
    sys.exit(main())
  File "/home/jrollins/.conda/envs/igwn/lib/python3.9/site-packages/ndscope/__main__.py", line 391, in main
    sys.exit(app.exec_())
  File "/home/jrollins/.conda/envs/igwn/lib/python3.9/site-packages/pyqtgraph/widgets/GraphicsView.py", line 137, in paintEvent
    return super().paintEvent(ev)
  File "/home/jrollins/.conda/envs/igwn/lib/python3.9/site-packages/pyqtgraph/debug.py", line 128, in w
    printExc('Ignored exception:')
  --- exception caught here ---
  File "/home/jrollins/.conda/envs/igwn/lib/python3.9/site-packages/pyqtgraph/debug.py", line 126, in w
    func(*args, **kwds)
  File "/home/jrollins/.conda/envs/igwn/lib/python3.9/site-packages/pyqtgraph/graphicsItems/PlotCurveItem.py", line 905, in paint
    p.drawLines(*self._getLineSegments())
TypeError: arguments did not match any overloaded call:
  drawLines(self, PyQt5.sip.array[QLineF]): not enough arguments
  drawLines(self, QLineF, *): not enough arguments
  drawLines(self, PyQt5.sip.array[Union[QPointF, QPoint]]): not enough arguments
  drawLines(self, Union[QPointF, QPoint], *): not enough arguments
  drawLines(self, PyQt5.sip.array[QLine]): not enough arguments
  drawLines(self, QLine, *): not enough arguments
  drawLines(self, PyQt5.sip.array[QPoint]): not enough arguments
  drawLines(self, QPoint, *): not enough arguments
  printExc('Ignored exception:')
```

### Tested environment(s)

 * PyQtGraph version: 0.13.1
 * Qt Python binding: `PyQt5 5.15.7 Qt 5.15.4`
 * Python version: 3.9.13
 * NumPy version: 1.23.3
 * Operating system: linux
 * Installation method: conda

### Additional context



Discussion:
Hi @jrollins 

Can you export an x and y array to a file and pass them over? 

Also by chance, what version of PyQt5-sip do you have?
Alternatively, if you can provide an example to trigger this issue within ndscope, I can try looking at that too...
Hey @j9ac9k, thanks so much for the response.  

pyqt5-sip is at 12.11.0

I've been trying to isolate the problem, but you should be able to duplicate it by running ndscope with the following command:
```
ndscope --nds fake FOO --time yesterday --window '(-2,0)' --line-width 2
```
It seems to have something to do with the line width being greater than 1, and something with the time (x) axis range ending at zero... 
There is a slightly different code path when using line width greater than 1; that's shown to be fairly robust so far but perhaps it's not as tested throughly as I thought.  Do you not get the error with line width being 1.0?
> ndscope --nds fake FOO --time yesterday --window '(-2,0)' --line-width 2

I installed ndscope via pip, giving me an error about `nds2` module not found; do I need to install ndscope in a conda environment or can I make it work using pip?
I can trigger the exception as follows:
1) Run PlotSpeedTest.py
2) set nsamples=1
3) set Width=2

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/PlotCurveItem.py b/pyqtgraph/graphicsItems/PlotCurveItem.py
--- a/pyqtgraph/graphicsItems/PlotCurveItem.py
+++ b/pyqtgraph/graphicsItems/PlotCurveItem.py
@@ -73,7 +73,7 @@ def get(self, size):
     def arrayToLineSegments(self, x, y, connect, finiteCheck):
         # analogue of arrayToQPath taking the same parameters
         if len(x) < 2:
-            return []
+            return [],
 
         connect_array = None
         if isinstance(connect, np.ndarray):


Test patch:
diff --git a/tests/graphicsItems/test_PlotCurveItem.py b/tests/graphicsItems/test_PlotCurveItem.py
--- a/tests/graphicsItems/test_PlotCurveItem.py
+++ b/tests/graphicsItems/test_PlotCurveItem.py
@@ -1,6 +1,7 @@
 import numpy as np
 
 import pyqtgraph as pg
+from pyqtgraph.graphicsItems.PlotCurveItem import LineSegments
 from tests.image_testing import assertImageApproved
 
 
@@ -35,3 +36,13 @@ def test_PlotCurveItem():
     assertImageApproved(p, 'plotcurveitem/connectarray', "Plot curve with connection array.")
 
     p.close()
+
+
+def test_LineSegments():
+    ls = LineSegments()
+
+    # test the boundary case where the dataset consists of a single point
+    xy = np.array([0.])
+    segs = ls.arrayToLineSegments(xy, xy, connect='all', finiteCheck=True)
+    assert isinstance(segs, tuple) and len(segs) in [1, 2]
+    assert len(segs[0]) == 0