Repository: Qiskit/qiskit

Issue:
Clifford simulator result() fails on any circuit
<!-- ⚠️ 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**: Latest master
- **Python version**: 3.7
- **Operating system**: Linux

### What is the current behavior?

When attempting to call execute() with the backend being the clifford simulator it always fails.

This was hit in trying to add some new tests that ran on all backends:

https://travis-ci.org/Qiskit/qiskit-terra/jobs/442859915#L1694

```
1: concurrent.futures.process._RemoteTraceback: 
1: """
1: Traceback (most recent call last):
1:   File "/opt/python/3.5.6/lib/python3.5/concurrent/futures/process.py", line 175, in _process_worker
1:     r = call_item.fn(*call_item.args, **call_item.kwargs)
1:   File "/home/travis/build/Qiskit/qiskit-terra/qiskit/backends/aer/qasm_simulator.py", line 151, in _run_job
1:     if 'config' in qobj:
1: TypeError: argument of type 'Qobj' is not iterable
1: """
1: 
1: The above exception was the direct cause of the following exception:
1: 
1: Traceback (most recent call last):
1:   File "/home/travis/build/Qiskit/qiskit-terra/test/python/test_result.py", line 136, in test_add_aer
1:     result_a = qiskit.execute(qc1, backend).result()
1:   File "/home/travis/build/Qiskit/qiskit-terra/qiskit/backends/aer/aerjob.py", line 37, in _wrapper
1:     return func(self, *args, **kwargs)
1:   File "/home/travis/build/Qiskit/qiskit-terra/qiskit/backends/aer/aerjob.py", line 92, in result
1:     return self._future.result(timeout=timeout)
1:   File "/opt/python/3.5.6/lib/python3.5/concurrent/futures/_base.py", line 405, in result
1:     return self.__get_result()
1:   File "/opt/python/3.5.6/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
1:     raise self._exception
1: TypeError: argument of type 'Qobj' is not iterable
```


### Steps to reproduce the problem

Build any circuit and run execute() and result() on it with the clifford simulator backend. For example:

```
import qiskit
                          
qr = qiskit.QuantumRegister(2)
cr = qiskit.ClassicalRegister(2)
qc = qiskit.QuantumCircuit(qr, cr)

qc.h(qr[0])
qc.measure(qr, cr)
    
qiskit.execute(qc, 'clifford_simulator').result()
```

### What is the expected behavior?

The circuit runs on the simulator.


### Suggested solutions

Fix the underlying issue



Discussion:

Resolving patch:
diff --git a/qiskit/backends/aer/qasm_simulator.py b/qiskit/backends/aer/qasm_simulator.py
--- a/qiskit/backends/aer/qasm_simulator.py
+++ b/qiskit/backends/aer/qasm_simulator.py
@@ -23,6 +23,7 @@
 from qiskit.result._utils import copy_qasm_from_qobj_into_result, result_from_old_style_dict
 from qiskit.backends import BaseBackend
 from qiskit.backends.aer.aerjob import AerJob
+from qiskit.qobj import Qobj
 from qiskit.qobj import qobj_to_dict
 
 logger = logging.getLogger(__name__)
@@ -146,13 +147,18 @@ def run(self, qobj):
         return aer_job
 
     def _run_job(self, job_id, qobj):
+        if isinstance(qobj, Qobj):
+            qobj_dict = qobj.as_dict()
+        else:
+            qobj_dict = qobj
         self._validate()
         # set backend to Clifford simulator
-        if 'config' in qobj:
-            qobj['config']['simulator'] = 'clifford'
+        if 'config' in qobj_dict:
+            qobj_dict['config']['simulator'] = 'clifford'
         else:
-            qobj['config'] = {'simulator': 'clifford'}
+            qobj_dict['config'] = {'simulator': 'clifford'}
 
+        qobj = Qobj.from_dict(qobj_dict)
         result = run(qobj, self._configuration['exe'])
         result['job_id'] = job_id
 


Test patch: