Repository: Qiskit/qiskit

Issue:
Two Local 'reps' doesn't raise 'TypeError' for string input
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**:0.17.2
- **Python version**:3.8.5
- **Operating system**:Linux Mint 20

### What is the current behavior?
When a string is supplied to reps parameter of TwoLocal , it tries raising ValueError which raises another error


### Steps to reproduce the problem
Working Example
```
import qiskit
two = qiskit.circuit.library.TwoLocal(3, 'ry', 'cx', 'full', reps='1', insert_barriers=True)
```


### What is the expected behavior?
If possible the string value should be converted to int and if not possible TypeError should be raised.


### Suggested solutions
Try converting string to int, if error occurs raise TypeError


Discussion:
Is it possible for me to work on this myself?
> Is it possible for me to work on this myself?

Of course, that would be great if you could do a PR that fixes this - also please include a unit test that asserts the error that is thrown, when you pass in such a value, is as expected. That way we can make sure it continues to work as expected since evidently this was missed in the unit testing before. You will find a set of tests already for TwoLocal here https://github.com/Qiskit/qiskit-terra/blob/e122c9c0cef78d1ba4ac57442cd03fb0363ba93c/test/python/circuit/library/test_nlocal.py#L402 and you can simply add another there.

Resolving patch:
diff --git a/qiskit/circuit/library/n_local/n_local.py b/qiskit/circuit/library/n_local/n_local.py
--- a/qiskit/circuit/library/n_local/n_local.py
+++ b/qiskit/circuit/library/n_local/n_local.py
@@ -112,6 +112,7 @@ def __init__(
         Raises:
             ImportError: If an ``initial_state`` is specified but Qiskit Aqua is not installed.
             ValueError: If reps parameter is less than or equal to 0.
+            TypeError: If reps parameter is not an int value.
         """
         super().__init__(name=name)
 
@@ -134,6 +135,9 @@ def __init__(
         self._data = None
         self._bounds = None
 
+        if int(reps) != reps:
+            raise TypeError("The value of reps should be int")
+
         if reps < 0:
             raise ValueError("The value of reps should be larger than or equal to 0")
 


Test patch:
diff --git a/test/python/circuit/library/test_nlocal.py b/test/python/circuit/library/test_nlocal.py
--- a/test/python/circuit/library/test_nlocal.py
+++ b/test/python/circuit/library/test_nlocal.py
@@ -51,6 +51,24 @@ def test_if_reps_is_negative(self):
         with self.assertRaises(ValueError):
             _ = NLocal(reps=-1)
 
+    def test_if_reps_is_str(self):
+        """Test to check if proper error is raised for str value of reps"""
+        with self.assertRaises(TypeError):
+            _ = NLocal(reps="3")
+
+    def test_if_reps_is_float(self):
+        """Test to check if proper error is raised for float value of reps"""
+        with self.assertRaises(TypeError):
+            _ = NLocal(reps=5.6)
+
+    def test_if_reps_is_npint32(self):
+        """Equality test for reps with int value and np.int32 value"""
+        self.assertEqual(NLocal(reps=3), NLocal(reps=np.int32(3)))
+
+    def test_if_reps_is_npint64(self):
+        """Equality test for reps with int value and np.int64 value"""
+        self.assertEqual(NLocal(reps=3), NLocal(reps=np.int64(3)))
+
     def test_reps_setter_when_negative(self):
         """Test to check if setter raises error for reps < 0"""
         nlocal = NLocal(reps=1)