We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
HDF5Exporter: throws error when curves aren't the same length
When trying to save data from a graph as an hdf5 file, the HDF5Exporter throws and error when you have multiple curves with differing lengths. This looks to be because the numpy.array(data).astype('double') can't handle lists with different lengths. Below is a traceback from the error. This occurs when trying to save data from the "Multiple curves" graph in the "Basic Plotting" example.

````
Traceback (most recent call last):
  File "/home/jchrist/PycharmProjects/lib/python3.5/site-packages/pyqtgraph/exporters/Exporter.py", line 77, in fileSaveFinished
    self.export(fileName=fileName, **self.fileDialog.opts)
  File "/home/jchrist/PycharmProjects/lib/python3.5/site-packages/pyqtgraph/exporters/HDF5Exporter.py", line 55, in export
    fdata = numpy.array(data).astype('double')
ValueError: setting an array element with a sequence.
````

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pyqtgraph/exporters/HDF5Exporter.py`
Content:
```
1 from ..Qt import QtGui, QtCore
2 from .Exporter import Exporter
3 from ..parametertree import Parameter
4 from .. import PlotItem
5 
6 import numpy 
7 try:
8     import h5py
9     HAVE_HDF5 = True
10 except ImportError:
11     HAVE_HDF5 = False
12     
13 __all__ = ['HDF5Exporter']
14 
15     
16 class HDF5Exporter(Exporter):
17     Name = "HDF5 Export: plot (x,y)"
18     windows = []
19     allowCopy = False
20 
21     def __init__(self, item):
22         Exporter.__init__(self, item)
23         self.params = Parameter(name='params', type='group', children=[
24             {'name': 'Name', 'type': 'str', 'value': 'Export',},
25             {'name': 'columnMode', 'type': 'list', 'values': ['(x,y) per plot', '(x,y,y,y) for all plots']},
26         ])
27         
28     def parameters(self):
29         return self.params
30     
31     def export(self, fileName=None):
32         if not HAVE_HDF5:
33             raise RuntimeError("This exporter requires the h5py package, "
34                                "but it was not importable.")
35         
36         if not isinstance(self.item, PlotItem):
37             raise Exception("Must have a PlotItem selected for HDF5 export.")
38         
39         if fileName is None:
40             self.fileSaveDialog(filter=["*.h5", "*.hdf", "*.hd5"])
41             return
42         dsname = self.params['Name']
43         fd = h5py.File(fileName, 'a') # forces append to file... 'w' doesn't seem to "delete/overwrite"
44         data = []
45 
46         appendAllX = self.params['columnMode'] == '(x,y) per plot'
47         #print dir(self.item.curves[0])
48         tlen = 0
49         for i, c in enumerate(self.item.curves):
50             d = c.getData()
51             if i > 0 and len(d[0]) != tlen:
52                 raise ValueError ("HDF5 Export requires all curves in plot to have same length")
53             if appendAllX or i == 0:
54                 data.append(d[0])
55                 tlen = len(d[0])
56             data.append(d[1])
57 
58 
59         fdata = numpy.array(data).astype('double')
60         dset = fd.create_dataset(dsname, data=fdata)
61         fd.close()
62 
63 if HAVE_HDF5:
64     HDF5Exporter.register()
65
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pyqtgraph/exporters/HDF5Exporter.py b/pyqtgraph/exporters/HDF5Exporter.py
--- a/pyqtgraph/exporters/HDF5Exporter.py
+++ b/pyqtgraph/exporters/HDF5Exporter.py
@@ -44,20 +44,27 @@
         data = []
 
         appendAllX = self.params['columnMode'] == '(x,y) per plot'
-        #print dir(self.item.curves[0])
-        tlen = 0
-        for i, c in enumerate(self.item.curves):
-            d = c.getData()
-            if i > 0 and len(d[0]) != tlen:
-                raise ValueError ("HDF5 Export requires all curves in plot to have same length")
-            if appendAllX or i == 0:
-                data.append(d[0])
-                tlen = len(d[0])
-            data.append(d[1])
+        # Check if the arrays are ragged
+        len_first = len(self.item.curves[0].getData()[0]) if self.item.curves[0] else None
+        ragged = any(len(i.getData()[0]) != len_first for i in self.item.curves)
 
+        if ragged:
+            dgroup = fd.create_group(dsname)
+            for i, c in enumerate(self.item.curves):
+                d = c.getData()
+                fdata = numpy.array([d[0], d[1]]).astype('double')
+                cname = c.name() if c.name() is not None else str(i)
+                dset = dgroup.create_dataset(cname, data=fdata)
+        else:
+            for i, c in enumerate(self.item.curves):
+                d = c.getData()
+                if appendAllX or i == 0:
+                    data.append(d[0])
+                data.append(d[1])
+
+            fdata = numpy.array(data).astype('double')
+            dset = fd.create_dataset(dsname, data=fdata)
 
-        fdata = numpy.array(data).astype('double')
-        dset = fd.create_dataset(dsname, data=fdata)
         fd.close()
 
 if HAVE_HDF5:

{"golden_diff": "diff --git a/pyqtgraph/exporters/HDF5Exporter.py b/pyqtgraph/exporters/HDF5Exporter.py\n--- a/pyqtgraph/exporters/HDF5Exporter.py\n+++ b/pyqtgraph/exporters/HDF5Exporter.py\n@@ -44,20 +44,27 @@\n         data = []\n \n         appendAllX = self.params['columnMode'] == '(x,y) per plot'\n-        #print dir(self.item.curves[0])\n-        tlen = 0\n-        for i, c in enumerate(self.item.curves):\n-            d = c.getData()\n-            if i > 0 and len(d[0]) != tlen:\n-                raise ValueError (\"HDF5 Export requires all curves in plot to have same length\")\n-            if appendAllX or i == 0:\n-                data.append(d[0])\n-                tlen = len(d[0])\n-            data.append(d[1])\n+        # Check if the arrays are ragged\n+        len_first = len(self.item.curves[0].getData()[0]) if self.item.curves[0] else None\n+        ragged = any(len(i.getData()[0]) != len_first for i in self.item.curves)\n \n+        if ragged:\n+            dgroup = fd.create_group(dsname)\n+            for i, c in enumerate(self.item.curves):\n+                d = c.getData()\n+                fdata = numpy.array([d[0], d[1]]).astype('double')\n+                cname = c.name() if c.name() is not None else str(i)\n+                dset = dgroup.create_dataset(cname, data=fdata)\n+        else:\n+            for i, c in enumerate(self.item.curves):\n+                d = c.getData()\n+                if appendAllX or i == 0:\n+                    data.append(d[0])\n+                data.append(d[1])\n+\n+            fdata = numpy.array(data).astype('double')\n+            dset = fd.create_dataset(dsname, data=fdata)\n \n-        fdata = numpy.array(data).astype('double')\n-        dset = fd.create_dataset(dsname, data=fdata)\n         fd.close()\n \n if HAVE_HDF5:\n", "issue": "HDF5Exporter: throws error when curves aren't the same length\nWhen trying to save data from a graph as an hdf5 file, the HDF5Exporter throws and error when you have multiple curves with differing lengths. This looks to be because the numpy.array(data).astype('double') can't handle lists with different lengths. Below is a traceback from the error. This occurs when trying to save data from the \"Multiple curves\" graph in the \"Basic Plotting\" example.\r\n\r\n````\r\nTraceback (most recent call last):\r\n  File \"/home/jchrist/PycharmProjects/lib/python3.5/site-packages/pyqtgraph/exporters/Exporter.py\", line 77, in fileSaveFinished\r\n    self.export(fileName=fileName, **self.fileDialog.opts)\r\n  File \"/home/jchrist/PycharmProjects/lib/python3.5/site-packages/pyqtgraph/exporters/HDF5Exporter.py\", line 55, in export\r\n    fdata = numpy.array(data).astype('double')\r\nValueError: setting an array element with a sequence.\r\n````\n", "before_files": [{"content": "from ..Qt import QtGui, QtCore\nfrom .Exporter import Exporter\nfrom ..parametertree import Parameter\nfrom .. import PlotItem\n\nimport numpy \ntry:\n    import h5py\n    HAVE_HDF5 = True\nexcept ImportError:\n    HAVE_HDF5 = False\n    \n__all__ = ['HDF5Exporter']\n\n    \nclass HDF5Exporter(Exporter):\n    Name = \"HDF5 Export: plot (x,y)\"\n    windows = []\n    allowCopy = False\n\n    def __init__(self, item):\n        Exporter.__init__(self, item)\n        self.params = Parameter(name='params', type='group', children=[\n            {'name': 'Name', 'type': 'str', 'value': 'Export',},\n            {'name': 'columnMode', 'type': 'list', 'values': ['(x,y) per plot', '(x,y,y,y) for all plots']},\n        ])\n        \n    def parameters(self):\n        return self.params\n    \n    def export(self, fileName=None):\n        if not HAVE_HDF5:\n            raise RuntimeError(\"This exporter requires the h5py package, \"\n                               \"but it was not importable.\")\n        \n        if not isinstance(self.item, PlotItem):\n            raise Exception(\"Must have a PlotItem selected for HDF5 export.\")\n        \n        if fileName is None:\n            self.fileSaveDialog(filter=[\"*.h5\", \"*.hdf\", \"*.hd5\"])\n            return\n        dsname = self.params['Name']\n        fd = h5py.File(fileName, 'a') # forces append to file... 'w' doesn't seem to \"delete/overwrite\"\n        data = []\n\n        appendAllX = self.params['columnMode'] == '(x,y) per plot'\n        #print dir(self.item.curves[0])\n        tlen = 0\n        for i, c in enumerate(self.item.curves):\n            d = c.getData()\n            if i > 0 and len(d[0]) != tlen:\n                raise ValueError (\"HDF5 Export requires all curves in plot to have same length\")\n            if appendAllX or i == 0:\n                data.append(d[0])\n                tlen = len(d[0])\n            data.append(d[1])\n\n\n        fdata = numpy.array(data).astype('double')\n        dset = fd.create_dataset(dsname, data=fdata)\n        fd.close()\n\nif HAVE_HDF5:\n    HDF5Exporter.register()\n", "path": "pyqtgraph/exporters/HDF5Exporter.py"}], "after_files": [{"content": "from ..Qt import QtGui, QtCore\nfrom .Exporter import Exporter\nfrom ..parametertree import Parameter\nfrom .. import PlotItem\n\nimport numpy \ntry:\n    import h5py\n    HAVE_HDF5 = True\nexcept ImportError:\n    HAVE_HDF5 = False\n    \n__all__ = ['HDF5Exporter']\n\n    \nclass HDF5Exporter(Exporter):\n    Name = \"HDF5 Export: plot (x,y)\"\n    windows = []\n    allowCopy = False\n\n    def __init__(self, item):\n        Exporter.__init__(self, item)\n        self.params = Parameter(name='params', type='group', children=[\n            {'name': 'Name', 'type': 'str', 'value': 'Export',},\n            {'name': 'columnMode', 'type': 'list', 'values': ['(x,y) per plot', '(x,y,y,y) for all plots']},\n        ])\n        \n    def parameters(self):\n        return self.params\n    \n    def export(self, fileName=None):\n        if not HAVE_HDF5:\n            raise RuntimeError(\"This exporter requires the h5py package, \"\n                               \"but it was not importable.\")\n        \n        if not isinstance(self.item, PlotItem):\n            raise Exception(\"Must have a PlotItem selected for HDF5 export.\")\n        \n        if fileName is None:\n            self.fileSaveDialog(filter=[\"*.h5\", \"*.hdf\", \"*.hd5\"])\n            return\n        dsname = self.params['Name']\n        fd = h5py.File(fileName, 'a') # forces append to file... 'w' doesn't seem to \"delete/overwrite\"\n        data = []\n\n        appendAllX = self.params['columnMode'] == '(x,y) per plot'\n        # Check if the arrays are ragged\n        len_first = len(self.item.curves[0].getData()[0]) if self.item.curves[0] else None\n        ragged = any(len(i.getData()[0]) != len_first for i in self.item.curves)\n\n        if ragged:\n            dgroup = fd.create_group(dsname)\n            for i, c in enumerate(self.item.curves):\n                d = c.getData()\n                fdata = numpy.array([d[0], d[1]]).astype('double')\n                cname = c.name() if c.name() is not None else str(i)\n                dset = dgroup.create_dataset(cname, data=fdata)\n        else:\n            for i, c in enumerate(self.item.curves):\n                d = c.getData()\n                if appendAllX or i == 0:\n                    data.append(d[0])\n                data.append(d[1])\n\n            fdata = numpy.array(data).astype('double')\n            dset = fd.create_dataset(dsname, data=fdata)\n\n        fd.close()\n\nif HAVE_HDF5:\n    HDF5Exporter.register()\n", "path": "pyqtgraph/exporters/HDF5Exporter.py"}]}