Repository: Qiskit/qiskit

Issue:
Add informative error message when the argument "shots" passed to the execute function is not of type int
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?
execute(circuit, backend = Aer.get_backend('qasm_simulator), shots = "1024") doesn't give an informative error message (Issue number 842 in qiskit-aer). Add an informative error message.

This isssue was posted in qiskit-aer which is a wrong place for it. Creating a new issue at qiskit-terra (which is relevant to it) and creating a pull request for a solution 




Discussion:
Can I work on this?
Certainly, assigning to you. 
Hey, I just looked through the problem. Can someone specify more precisely what the problem. I am new to this and help would be much appreciated, thanks!
@taalexander , @siddharthdangwal  Hey can you help me out, in specifying the error. Is it because the value for shots is entered as a string and an error message should be displayed for that?
@coder-mtv, I would start by trying the example @siddharthdangwal posted above and seeing where the error is raised. I think a proper error should be added somewhere around here https://github.com/Qiskit/qiskit-terra/blob/995ac92376cfa632b124e171023c779bd2f3119b/qiskit/compiler/assemble.py#L216.
Hey @taalexander , I have fixed the issue, I believe. I will upload it shortly. If there is still an error, could you please reassign it to me?

I will be uploading the fix around 10 hours later. It would be great, if you could merge by the 14th itself!
Hello, @coder-mtv it seems like @siddharthdangwal had made a PR #4880 and we missed this.
Hey @taalexander , so is the issue fixed, or can I still do it? I didn't get the message properly
I'm sorry @coder-mtv, it seems like there is already a solution that is mostly done. I don't think it would be a good use of time to continue on this, I am sorry for causing you to waste your time. Would you like me to to help find another good issue to work on? 
You could also help review #4880 and compare it with your solution.
@taalexander but I encountered the error that was referred to in this issue, so is it fixed yet actually?
@taalexander Is there any way, I could do this issue, as I'm applying for the advocates program and a contribution would help!
@coder-mtv the fix is here https://github.com/Qiskit/qiskit-terra/pull/4880. If it is not updated by @siddharthdangwal in about a weeks time, I will reassign.
Thanks! @taalexander 
Hi! Is this problem still open?

@siddharthdangwal got unresponsive. Do you want to work on this @coder-mtv ? 

Feel free to continue the code in #4880. If you do, make sure you respect the original authorship as co-author. Otherwise, you can restart a new PR.

If @coder-mtv is not responding in the coming week. Is @tgag17 interested?
I will work on it @taalexander 
Hey, is this issue still open? Can I work on it?
@taalexander could you please assign this issue to me? I want to try this out.

Resolving patch:
diff --git a/qiskit/compiler/assemble.py b/qiskit/compiler/assemble.py
--- a/qiskit/compiler/assemble.py
+++ b/qiskit/compiler/assemble.py
@@ -190,7 +190,8 @@ def _parse_common_args(backend, qobj_id, qobj_header, shots,
 
     Raises:
         QiskitError: if the memory arg is True and the backend does not support
-            memory. Also if shots exceeds max_shots for the configured backend.
+            memory. Also if shots exceeds max_shots for the configured backend. Also if
+            the type of shots is not int.
     """
     # grab relevant info from backend if it exists
     backend_config = None
@@ -221,6 +222,9 @@ def _parse_common_args(backend, qobj_id, qobj_header, shots,
             shots = min(1024, max_shots)
         else:
             shots = 1024
+    elif not isinstance(shots, int):
+        raise QiskitError(
+            "Argument 'shots' should be of type 'int'")
     elif max_shots and max_shots < shots:
         raise QiskitError(
             'Number of shots specified: %s exceeds max_shots property of the '


Test patch:
diff --git a/test/python/compiler/test_assembler.py b/test/python/compiler/test_assembler.py
--- a/test/python/compiler/test_assembler.py
+++ b/test/python/compiler/test_assembler.py
@@ -113,6 +113,11 @@ def test_shots_greater_than_max_shots(self):
         backend = FakeYorktown()
         self.assertRaises(QiskitError, assemble, backend, shots=1024000)
 
+    def test_shots_not_of_type_int(self):
+        """Test assembling with shots having type other than int"""
+        backend = FakeYorktown()
+        self.assertRaises(QiskitError, assemble, backend, shots="1024")
+
     def test_default_shots_greater_than_max_shots(self):
         """Test assembling with default shots greater than max shots"""
         backend = FakeYorktown()