We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can not combine the Result object from the same backend (statevector)
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Informations

- **Qiskit Terra version**: the master branch
- **Python version**: 3.6.5
- **Operating system**: macOS 10.13

### What is the current behavior?
raise error

```
Traceback (most recent call last):
  File "/Users/rchen/Developer/Quantum/qiskit-terra/qiskit/result/_result.py", line 125, in __add__
    copy_of_self += other
  File "/Users/rchen/Developer/Quantum/qiskit-terra/qiskit/result/_result.py", line 108, in __iadd__
    raise QISKitError('Result objects from different backends cannot be combined.')
qiskit._qiskiterror.QISKitError: 'Result objects from different backends cannot be combined.'
```

### Steps to reproduce the problem
Code
```python
from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister
import qiskit as qk
import numpy as np

num_qubits = 2

q = QuantumRegister(num_qubits, name='q')
c = ClassicalRegister(num_qubits, name='c')
circuits = QuantumCircuit(q, c)
param_idx = 0
for qubit in range(num_qubits):
    circuits.u3(0.0, 0.0, 0.0, q[qubit])
    circuits.u1(3.0, q[qubit])

# circuits.measure(q, c)


my_backend = qk.Aer.get_backend('statevector_simulator')
qobj = qk.compile(circuits=circuits, backend=my_backend)
job = my_backend.run(qobj)
result_a = job.result()

qobj = qk.compile(circuits=circuits, backend=my_backend)
job = my_backend.run(qobj)
result_b = job.result()

result = result_a + result_b

```


### What is the expected behavior?
Result objects are combined without error


### Suggested solutions
None

Note: If I change the backend to `qasm_simulator`, there is no error.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `qiskit/backends/aer/statevector_simulator.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Copyright 2017, IBM.
4 #
5 # This source code is licensed under the Apache License, Version 2.0 found in
6 # the LICENSE.txt file in the root directory of this source tree.
7 
8 # pylint: disable=invalid-name
9 
10 """
11 Interface to C++ quantum circuit simulator with realistic noise.
12 """
13 
14 import logging
15 import uuid
16 
17 from qiskit.qobj import QobjInstruction
18 from .qasm_simulator import QasmSimulator
19 from ._simulatorerror import SimulatorError
20 from .aerjob import AerJob
21 
22 logger = logging.getLogger(__name__)
23 
24 
25 class StatevectorSimulator(QasmSimulator):
26     """C++ statevector simulator"""
27 
28     DEFAULT_CONFIGURATION = {
29         'name': 'statevector_simulator',
30         'url': 'https://github.com/QISKit/qiskit-terra/src/qasm-simulator-cpp',
31         'simulator': True,
32         'local': True,
33         'description': 'A C++ statevector simulator for qobj files',
34         'coupling_map': 'all-to-all',
35         'basis_gates': 'u1,u2,u3,cx,cz,id,x,y,z,h,s,sdg,t,tdg,rzz,load,save,snapshot'
36     }
37 
38     def __init__(self, configuration=None, provider=None):
39         super().__init__(configuration=configuration or self.DEFAULT_CONFIGURATION.copy(),
40                          provider=provider)
41 
42     def run(self, qobj):
43         """Run a qobj on the the backend."""
44         job_id = str(uuid.uuid4())
45         aer_job = AerJob(self, job_id, self._run_job, qobj)
46         aer_job.submit()
47         return aer_job
48 
49     def _run_job(self, job_id, qobj):
50         """Run a Qobj on the backend."""
51         self._validate(qobj)
52         final_state_key = 32767  # Internal key for final state snapshot
53         # Add final snapshots to circuits
54         for experiment in qobj.experiments:
55             experiment.instructions.append(
56                 QobjInstruction(name='snapshot', params=[final_state_key])
57             )
58         result = super()._run_job(job_id, qobj)
59         # Replace backend name with current backend
60         result.backend_name = self.name
61         # Extract final state snapshot and move to 'statevector' data field
62         for experiment_result in result.results.values():
63             snapshots = experiment_result.snapshots
64             if str(final_state_key) in snapshots:
65                 final_state_key = str(final_state_key)
66             # Pop off final snapshot added above
67             final_state = snapshots.pop(final_state_key, None)
68             final_state = final_state['statevector'][0]
69             # Add final state to results data
70             experiment_result.data['statevector'] = final_state
71             # Remove snapshot dict if empty
72             if snapshots == {}:
73                 experiment_result.data.pop('snapshots', None)
74         return result
75 
76     def _validate(self, qobj):
77         """Semantic validations of the qobj which cannot be done via schemas.
78         Some of these may later move to backend schemas.
79 
80         1. No shots
81         2. No measurements in the middle
82         """
83         if qobj.config.shots != 1:
84             logger.info("statevector simulator only supports 1 shot. "
85                         "Setting shots=1.")
86             qobj.config.shots = 1
87         for experiment in qobj.experiments:
88             if getattr(experiment.config, 'shots', 1) != 1:
89                 logger.info("statevector simulator only supports 1 shot. "
90                             "Setting shots=1 for circuit %s.", experiment.name)
91                 experiment.config.shots = 1
92             for op in experiment.instructions:
93                 if op.name in ['measure', 'reset']:
94                     raise SimulatorError(
95                         "In circuit {}: statevector simulator does not support "
96                         "measure or reset.".format(experiment.header.name))
97
```

Path: `qiskit/backends/aer/statevector_simulator_py.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Copyright 2017, IBM.
4 #
5 # This source code is licensed under the Apache License, Version 2.0 found in
6 # the LICENSE.txt file in the root directory of this source tree.
7 
8 # pylint: disable=invalid-name
9 
10 """Contains a (slow) python statevector simulator.
11 
12 It simulates the statevector through a quantum circuit. It is exponential in
13 the number of qubits.
14 
15 We advise using the c++ simulator or online simulator for larger size systems.
16 
17 The input is a qobj dictionary and the output is a Result object.
18 
19 The input qobj to this simulator has no shots, no measures, no reset, no noise.
20 """
21 import logging
22 import uuid
23 
24 from qiskit.backends.aer.aerjob import AerJob
25 from qiskit.backends.aer._simulatorerror import SimulatorError
26 from qiskit.qobj import QobjInstruction
27 from .qasm_simulator_py import QasmSimulatorPy
28 
29 logger = logging.getLogger(__name__)
30 
31 
32 class StatevectorSimulatorPy(QasmSimulatorPy):
33     """Python statevector simulator."""
34 
35     DEFAULT_CONFIGURATION = {
36         'name': 'statevector_simulator_py',
37         'url': 'https://github.com/QISKit/qiskit-terra',
38         'simulator': True,
39         'local': True,
40         'description': 'A Python statevector simulator for qobj files',
41         'coupling_map': 'all-to-all',
42         'basis_gates': 'u1,u2,u3,cx,id,snapshot'
43     }
44 
45     def __init__(self, configuration=None, provider=None):
46         super().__init__(configuration=configuration or self.DEFAULT_CONFIGURATION.copy(),
47                          provider=provider)
48 
49     def run(self, qobj):
50         """Run qobj asynchronously.
51 
52         Args:
53             qobj (dict): job description
54 
55         Returns:
56             AerJob: derived from BaseJob
57         """
58         job_id = str(uuid.uuid4())
59         aer_job = AerJob(self, job_id, self._run_job, qobj)
60         aer_job.submit()
61         return aer_job
62 
63     def _run_job(self, job_id, qobj):
64         """Run a Qobj on the backend."""
65         self._validate(qobj)
66         final_state_key = 32767  # Internal key for final state snapshot
67         # Add final snapshots to circuits
68         for experiment in qobj.experiments:
69             experiment.instructions.append(
70                 QobjInstruction(name='snapshot', params=[final_state_key])
71             )
72         result = super()._run_job(job_id, qobj)
73         # Replace backend name with current backend
74         result.backend_name = self.name
75         # Extract final state snapshot and move to 'statevector' data field
76         for experiment_result in result.results.values():
77             snapshots = experiment_result.snapshots
78             if str(final_state_key) in snapshots:
79                 final_state_key = str(final_state_key)
80             # Pop off final snapshot added above
81             final_state = snapshots.pop(final_state_key, None)
82             final_state = final_state['statevector'][0]
83             # Add final state to results data
84             experiment_result.data['statevector'] = final_state
85             # Remove snapshot dict if empty
86             if snapshots == {}:
87                 experiment_result.data.pop('snapshots', None)
88         return result
89 
90     def _validate(self, qobj):
91         """Semantic validations of the qobj which cannot be done via schemas.
92         Some of these may later move to backend schemas.
93 
94         1. No shots
95         2. No measurements in the middle
96         """
97         if qobj.config.shots != 1:
98             logger.info("statevector simulator only supports 1 shot. "
99                         "Setting shots=1.")
100             qobj.config.shots = 1
101         for experiment in qobj.experiments:
102             if getattr(experiment.config, 'shots', 1) != 1:
103                 logger.info("statevector simulator only supports 1 shot. "
104                             "Setting shots=1 for circuit %s.", experiment.name)
105                 experiment.config.shots = 1
106             for op in experiment.instructions:
107                 if op.name in ['measure', 'reset']:
108                     raise SimulatorError(
109                         "In circuit {}: statevector simulator does not support "
110                         "measure or reset.".format(experiment.header.name))
111
```
--- 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/qiskit/backends/aer/statevector_simulator.py b/qiskit/backends/aer/statevector_simulator.py
--- a/qiskit/backends/aer/statevector_simulator.py
+++ b/qiskit/backends/aer/statevector_simulator.py
@@ -56,8 +56,6 @@
                 QobjInstruction(name='snapshot', params=[final_state_key])
             )
         result = super()._run_job(job_id, qobj)
-        # Replace backend name with current backend
-        result.backend_name = self.name
         # Extract final state snapshot and move to 'statevector' data field
         for experiment_result in result.results.values():
             snapshots = experiment_result.snapshots
diff --git a/qiskit/backends/aer/statevector_simulator_py.py b/qiskit/backends/aer/statevector_simulator_py.py
--- a/qiskit/backends/aer/statevector_simulator_py.py
+++ b/qiskit/backends/aer/statevector_simulator_py.py
@@ -70,8 +70,6 @@
                 QobjInstruction(name='snapshot', params=[final_state_key])
             )
         result = super()._run_job(job_id, qobj)
-        # Replace backend name with current backend
-        result.backend_name = self.name
         # Extract final state snapshot and move to 'statevector' data field
         for experiment_result in result.results.values():
             snapshots = experiment_result.snapshots

{"golden_diff": "diff --git a/qiskit/backends/aer/statevector_simulator.py b/qiskit/backends/aer/statevector_simulator.py\n--- a/qiskit/backends/aer/statevector_simulator.py\n+++ b/qiskit/backends/aer/statevector_simulator.py\n@@ -56,8 +56,6 @@\n                 QobjInstruction(name='snapshot', params=[final_state_key])\n             )\n         result = super()._run_job(job_id, qobj)\n-        # Replace backend name with current backend\n-        result.backend_name = self.name\n         # Extract final state snapshot and move to 'statevector' data field\n         for experiment_result in result.results.values():\n             snapshots = experiment_result.snapshots\ndiff --git a/qiskit/backends/aer/statevector_simulator_py.py b/qiskit/backends/aer/statevector_simulator_py.py\n--- a/qiskit/backends/aer/statevector_simulator_py.py\n+++ b/qiskit/backends/aer/statevector_simulator_py.py\n@@ -70,8 +70,6 @@\n                 QobjInstruction(name='snapshot', params=[final_state_key])\n             )\n         result = super()._run_job(job_id, qobj)\n-        # Replace backend name with current backend\n-        result.backend_name = self.name\n         # Extract final state snapshot and move to 'statevector' data field\n         for experiment_result in result.results.values():\n             snapshots = experiment_result.snapshots\n", "issue": "Can not combine the Result object from the same backend (statevector)\n<!-- \u26a0\ufe0f If you do not respect this template, your issue will be closed -->\r\n<!-- \u26a0\ufe0f Make sure to browse the opened and closed issues -->\r\n\r\n### Informations\r\n\r\n- **Qiskit Terra version**: the master branch\r\n- **Python version**: 3.6.5\r\n- **Operating system**: macOS 10.13\r\n\r\n### What is the current behavior?\r\nraise error\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/rchen/Developer/Quantum/qiskit-terra/qiskit/result/_result.py\", line 125, in __add__\r\n    copy_of_self += other\r\n  File \"/Users/rchen/Developer/Quantum/qiskit-terra/qiskit/result/_result.py\", line 108, in __iadd__\r\n    raise QISKitError('Result objects from different backends cannot be combined.')\r\nqiskit._qiskiterror.QISKitError: 'Result objects from different backends cannot be combined.'\r\n```\r\n\r\n### Steps to reproduce the problem\r\nCode\r\n```python\r\nfrom qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister\r\nimport qiskit as qk\r\nimport numpy as np\r\n\r\nnum_qubits = 2\r\n\r\nq = QuantumRegister(num_qubits, name='q')\r\nc = ClassicalRegister(num_qubits, name='c')\r\ncircuits = QuantumCircuit(q, c)\r\nparam_idx = 0\r\nfor qubit in range(num_qubits):\r\n    circuits.u3(0.0, 0.0, 0.0, q[qubit])\r\n    circuits.u1(3.0, q[qubit])\r\n\r\n# circuits.measure(q, c)\r\n\r\n\r\nmy_backend = qk.Aer.get_backend('statevector_simulator')\r\nqobj = qk.compile(circuits=circuits, backend=my_backend)\r\njob = my_backend.run(qobj)\r\nresult_a = job.result()\r\n\r\nqobj = qk.compile(circuits=circuits, backend=my_backend)\r\njob = my_backend.run(qobj)\r\nresult_b = job.result()\r\n\r\nresult = result_a + result_b\r\n\r\n```\r\n\r\n\r\n### What is the expected behavior?\r\nResult objects are combined without error\r\n\r\n\r\n### Suggested solutions\r\nNone\r\n\r\nNote: If I change the backend to `qasm_simulator`, there is no error.\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2017, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n# pylint: disable=invalid-name\n\n\"\"\"\nInterface to C++ quantum circuit simulator with realistic noise.\n\"\"\"\n\nimport logging\nimport uuid\n\nfrom qiskit.qobj import QobjInstruction\nfrom .qasm_simulator import QasmSimulator\nfrom ._simulatorerror import SimulatorError\nfrom .aerjob import AerJob\n\nlogger = logging.getLogger(__name__)\n\n\nclass StatevectorSimulator(QasmSimulator):\n    \"\"\"C++ statevector simulator\"\"\"\n\n    DEFAULT_CONFIGURATION = {\n        'name': 'statevector_simulator',\n        'url': 'https://github.com/QISKit/qiskit-terra/src/qasm-simulator-cpp',\n        'simulator': True,\n        'local': True,\n        'description': 'A C++ statevector simulator for qobj files',\n        'coupling_map': 'all-to-all',\n        'basis_gates': 'u1,u2,u3,cx,cz,id,x,y,z,h,s,sdg,t,tdg,rzz,load,save,snapshot'\n    }\n\n    def __init__(self, configuration=None, provider=None):\n        super().__init__(configuration=configuration or self.DEFAULT_CONFIGURATION.copy(),\n                         provider=provider)\n\n    def run(self, qobj):\n        \"\"\"Run a qobj on the the backend.\"\"\"\n        job_id = str(uuid.uuid4())\n        aer_job = AerJob(self, job_id, self._run_job, qobj)\n        aer_job.submit()\n        return aer_job\n\n    def _run_job(self, job_id, qobj):\n        \"\"\"Run a Qobj on the backend.\"\"\"\n        self._validate(qobj)\n        final_state_key = 32767  # Internal key for final state snapshot\n        # Add final snapshots to circuits\n        for experiment in qobj.experiments:\n            experiment.instructions.append(\n                QobjInstruction(name='snapshot', params=[final_state_key])\n            )\n        result = super()._run_job(job_id, qobj)\n        # Replace backend name with current backend\n        result.backend_name = self.name\n        # Extract final state snapshot and move to 'statevector' data field\n        for experiment_result in result.results.values():\n            snapshots = experiment_result.snapshots\n            if str(final_state_key) in snapshots:\n                final_state_key = str(final_state_key)\n            # Pop off final snapshot added above\n            final_state = snapshots.pop(final_state_key, None)\n            final_state = final_state['statevector'][0]\n            # Add final state to results data\n            experiment_result.data['statevector'] = final_state\n            # Remove snapshot dict if empty\n            if snapshots == {}:\n                experiment_result.data.pop('snapshots', None)\n        return result\n\n    def _validate(self, qobj):\n        \"\"\"Semantic validations of the qobj which cannot be done via schemas.\n        Some of these may later move to backend schemas.\n\n        1. No shots\n        2. No measurements in the middle\n        \"\"\"\n        if qobj.config.shots != 1:\n            logger.info(\"statevector simulator only supports 1 shot. \"\n                        \"Setting shots=1.\")\n            qobj.config.shots = 1\n        for experiment in qobj.experiments:\n            if getattr(experiment.config, 'shots', 1) != 1:\n                logger.info(\"statevector simulator only supports 1 shot. \"\n                            \"Setting shots=1 for circuit %s.\", experiment.name)\n                experiment.config.shots = 1\n            for op in experiment.instructions:\n                if op.name in ['measure', 'reset']:\n                    raise SimulatorError(\n                        \"In circuit {}: statevector simulator does not support \"\n                        \"measure or reset.\".format(experiment.header.name))\n", "path": "qiskit/backends/aer/statevector_simulator.py"}, {"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2017, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n# pylint: disable=invalid-name\n\n\"\"\"Contains a (slow) python statevector simulator.\n\nIt simulates the statevector through a quantum circuit. It is exponential in\nthe number of qubits.\n\nWe advise using the c++ simulator or online simulator for larger size systems.\n\nThe input is a qobj dictionary and the output is a Result object.\n\nThe input qobj to this simulator has no shots, no measures, no reset, no noise.\n\"\"\"\nimport logging\nimport uuid\n\nfrom qiskit.backends.aer.aerjob import AerJob\nfrom qiskit.backends.aer._simulatorerror import SimulatorError\nfrom qiskit.qobj import QobjInstruction\nfrom .qasm_simulator_py import QasmSimulatorPy\n\nlogger = logging.getLogger(__name__)\n\n\nclass StatevectorSimulatorPy(QasmSimulatorPy):\n    \"\"\"Python statevector simulator.\"\"\"\n\n    DEFAULT_CONFIGURATION = {\n        'name': 'statevector_simulator_py',\n        'url': 'https://github.com/QISKit/qiskit-terra',\n        'simulator': True,\n        'local': True,\n        'description': 'A Python statevector simulator for qobj files',\n        'coupling_map': 'all-to-all',\n        'basis_gates': 'u1,u2,u3,cx,id,snapshot'\n    }\n\n    def __init__(self, configuration=None, provider=None):\n        super().__init__(configuration=configuration or self.DEFAULT_CONFIGURATION.copy(),\n                         provider=provider)\n\n    def run(self, qobj):\n        \"\"\"Run qobj asynchronously.\n\n        Args:\n            qobj (dict): job description\n\n        Returns:\n            AerJob: derived from BaseJob\n        \"\"\"\n        job_id = str(uuid.uuid4())\n        aer_job = AerJob(self, job_id, self._run_job, qobj)\n        aer_job.submit()\n        return aer_job\n\n    def _run_job(self, job_id, qobj):\n        \"\"\"Run a Qobj on the backend.\"\"\"\n        self._validate(qobj)\n        final_state_key = 32767  # Internal key for final state snapshot\n        # Add final snapshots to circuits\n        for experiment in qobj.experiments:\n            experiment.instructions.append(\n                QobjInstruction(name='snapshot', params=[final_state_key])\n            )\n        result = super()._run_job(job_id, qobj)\n        # Replace backend name with current backend\n        result.backend_name = self.name\n        # Extract final state snapshot and move to 'statevector' data field\n        for experiment_result in result.results.values():\n            snapshots = experiment_result.snapshots\n            if str(final_state_key) in snapshots:\n                final_state_key = str(final_state_key)\n            # Pop off final snapshot added above\n            final_state = snapshots.pop(final_state_key, None)\n            final_state = final_state['statevector'][0]\n            # Add final state to results data\n            experiment_result.data['statevector'] = final_state\n            # Remove snapshot dict if empty\n            if snapshots == {}:\n                experiment_result.data.pop('snapshots', None)\n        return result\n\n    def _validate(self, qobj):\n        \"\"\"Semantic validations of the qobj which cannot be done via schemas.\n        Some of these may later move to backend schemas.\n\n        1. No shots\n        2. No measurements in the middle\n        \"\"\"\n        if qobj.config.shots != 1:\n            logger.info(\"statevector simulator only supports 1 shot. \"\n                        \"Setting shots=1.\")\n            qobj.config.shots = 1\n        for experiment in qobj.experiments:\n            if getattr(experiment.config, 'shots', 1) != 1:\n                logger.info(\"statevector simulator only supports 1 shot. \"\n                            \"Setting shots=1 for circuit %s.\", experiment.name)\n                experiment.config.shots = 1\n            for op in experiment.instructions:\n                if op.name in ['measure', 'reset']:\n                    raise SimulatorError(\n                        \"In circuit {}: statevector simulator does not support \"\n                        \"measure or reset.\".format(experiment.header.name))\n", "path": "qiskit/backends/aer/statevector_simulator_py.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2017, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n# pylint: disable=invalid-name\n\n\"\"\"\nInterface to C++ quantum circuit simulator with realistic noise.\n\"\"\"\n\nimport logging\nimport uuid\n\nfrom qiskit.qobj import QobjInstruction\nfrom .qasm_simulator import QasmSimulator\nfrom ._simulatorerror import SimulatorError\nfrom .aerjob import AerJob\n\nlogger = logging.getLogger(__name__)\n\n\nclass StatevectorSimulator(QasmSimulator):\n    \"\"\"C++ statevector simulator\"\"\"\n\n    DEFAULT_CONFIGURATION = {\n        'name': 'statevector_simulator',\n        'url': 'https://github.com/QISKit/qiskit-terra/src/qasm-simulator-cpp',\n        'simulator': True,\n        'local': True,\n        'description': 'A C++ statevector simulator for qobj files',\n        'coupling_map': 'all-to-all',\n        'basis_gates': 'u1,u2,u3,cx,cz,id,x,y,z,h,s,sdg,t,tdg,rzz,load,save,snapshot'\n    }\n\n    def __init__(self, configuration=None, provider=None):\n        super().__init__(configuration=configuration or self.DEFAULT_CONFIGURATION.copy(),\n                         provider=provider)\n\n    def run(self, qobj):\n        \"\"\"Run a qobj on the the backend.\"\"\"\n        job_id = str(uuid.uuid4())\n        aer_job = AerJob(self, job_id, self._run_job, qobj)\n        aer_job.submit()\n        return aer_job\n\n    def _run_job(self, job_id, qobj):\n        \"\"\"Run a Qobj on the backend.\"\"\"\n        self._validate(qobj)\n        final_state_key = 32767  # Internal key for final state snapshot\n        # Add final snapshots to circuits\n        for experiment in qobj.experiments:\n            experiment.instructions.append(\n                QobjInstruction(name='snapshot', params=[final_state_key])\n            )\n        result = super()._run_job(job_id, qobj)\n        # Extract final state snapshot and move to 'statevector' data field\n        for experiment_result in result.results.values():\n            snapshots = experiment_result.snapshots\n            if str(final_state_key) in snapshots:\n                final_state_key = str(final_state_key)\n            # Pop off final snapshot added above\n            final_state = snapshots.pop(final_state_key, None)\n            final_state = final_state['statevector'][0]\n            # Add final state to results data\n            experiment_result.data['statevector'] = final_state\n            # Remove snapshot dict if empty\n            if snapshots == {}:\n                experiment_result.data.pop('snapshots', None)\n        return result\n\n    def _validate(self, qobj):\n        \"\"\"Semantic validations of the qobj which cannot be done via schemas.\n        Some of these may later move to backend schemas.\n\n        1. No shots\n        2. No measurements in the middle\n        \"\"\"\n        if qobj.config.shots != 1:\n            logger.info(\"statevector simulator only supports 1 shot. \"\n                        \"Setting shots=1.\")\n            qobj.config.shots = 1\n        for experiment in qobj.experiments:\n            if getattr(experiment.config, 'shots', 1) != 1:\n                logger.info(\"statevector simulator only supports 1 shot. \"\n                            \"Setting shots=1 for circuit %s.\", experiment.name)\n                experiment.config.shots = 1\n            for op in experiment.instructions:\n                if op.name in ['measure', 'reset']:\n                    raise SimulatorError(\n                        \"In circuit {}: statevector simulator does not support \"\n                        \"measure or reset.\".format(experiment.header.name))\n", "path": "qiskit/backends/aer/statevector_simulator.py"}, {"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2017, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n# pylint: disable=invalid-name\n\n\"\"\"Contains a (slow) python statevector simulator.\n\nIt simulates the statevector through a quantum circuit. It is exponential in\nthe number of qubits.\n\nWe advise using the c++ simulator or online simulator for larger size systems.\n\nThe input is a qobj dictionary and the output is a Result object.\n\nThe input qobj to this simulator has no shots, no measures, no reset, no noise.\n\"\"\"\nimport logging\nimport uuid\n\nfrom qiskit.backends.aer.aerjob import AerJob\nfrom qiskit.backends.aer._simulatorerror import SimulatorError\nfrom qiskit.qobj import QobjInstruction\nfrom .qasm_simulator_py import QasmSimulatorPy\n\nlogger = logging.getLogger(__name__)\n\n\nclass StatevectorSimulatorPy(QasmSimulatorPy):\n    \"\"\"Python statevector simulator.\"\"\"\n\n    DEFAULT_CONFIGURATION = {\n        'name': 'statevector_simulator_py',\n        'url': 'https://github.com/QISKit/qiskit-terra',\n        'simulator': True,\n        'local': True,\n        'description': 'A Python statevector simulator for qobj files',\n        'coupling_map': 'all-to-all',\n        'basis_gates': 'u1,u2,u3,cx,id,snapshot'\n    }\n\n    def __init__(self, configuration=None, provider=None):\n        super().__init__(configuration=configuration or self.DEFAULT_CONFIGURATION.copy(),\n                         provider=provider)\n\n    def run(self, qobj):\n        \"\"\"Run qobj asynchronously.\n\n        Args:\n            qobj (dict): job description\n\n        Returns:\n            AerJob: derived from BaseJob\n        \"\"\"\n        job_id = str(uuid.uuid4())\n        aer_job = AerJob(self, job_id, self._run_job, qobj)\n        aer_job.submit()\n        return aer_job\n\n    def _run_job(self, job_id, qobj):\n        \"\"\"Run a Qobj on the backend.\"\"\"\n        self._validate(qobj)\n        final_state_key = 32767  # Internal key for final state snapshot\n        # Add final snapshots to circuits\n        for experiment in qobj.experiments:\n            experiment.instructions.append(\n                QobjInstruction(name='snapshot', params=[final_state_key])\n            )\n        result = super()._run_job(job_id, qobj)\n        # Extract final state snapshot and move to 'statevector' data field\n        for experiment_result in result.results.values():\n            snapshots = experiment_result.snapshots\n            if str(final_state_key) in snapshots:\n                final_state_key = str(final_state_key)\n            # Pop off final snapshot added above\n            final_state = snapshots.pop(final_state_key, None)\n            final_state = final_state['statevector'][0]\n            # Add final state to results data\n            experiment_result.data['statevector'] = final_state\n            # Remove snapshot dict if empty\n            if snapshots == {}:\n                experiment_result.data.pop('snapshots', None)\n        return result\n\n    def _validate(self, qobj):\n        \"\"\"Semantic validations of the qobj which cannot be done via schemas.\n        Some of these may later move to backend schemas.\n\n        1. No shots\n        2. No measurements in the middle\n        \"\"\"\n        if qobj.config.shots != 1:\n            logger.info(\"statevector simulator only supports 1 shot. \"\n                        \"Setting shots=1.\")\n            qobj.config.shots = 1\n        for experiment in qobj.experiments:\n            if getattr(experiment.config, 'shots', 1) != 1:\n                logger.info(\"statevector simulator only supports 1 shot. \"\n                            \"Setting shots=1 for circuit %s.\", experiment.name)\n                experiment.config.shots = 1\n            for op in experiment.instructions:\n                if op.name in ['measure', 'reset']:\n                    raise SimulatorError(\n                        \"In circuit {}: statevector simulator does not support \"\n                        \"measure or reset.\".format(experiment.header.name))\n", "path": "qiskit/backends/aer/statevector_simulator_py.py"}]}