Repository: Qiskit/qiskit

Issue:
HHL new algorithm should be able to take python lists as matrix and vector but right now asking numpy arrays for these
<!-- ⚠️ 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.1
- **Python version**: 3.6
- **Operating system**: Windows 10

### What is the current behavior?

For the following code to execute -

from qiskit.algorithms.linear_solvers import HHL

hhl = HHL()
result = hhl.solve(matrix, vector)
result.state.draw('mpl', style='iqx')

matrix and vector have to be declared as numpy arrays like below but ideally they should just be python lists

import numpy as np

matrix = np.array([[1, -1/3], [-1/3, 1]])
vector = np.array([1, 0])

This problem is in the text book also

### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions





Discussion:
Since the textbook explicitly uses lists I agree. Thanks for reporting this! 👍🏻 
Hey! Maybe I could try a hand at this issue?Also, isnt HHL part of Aqua? So this issue should ideally be in that repo right?
Hey @charmerDark, were you able to fix this? If not then, I can give it a try 
@charmerDark feel free to work on this! HHL used to be part of Aqua, that's right, but we recently refactored Aqua into the application modules Qiskit Nature, Qiskit Optimization, Qiskit Machine Learning and Qiskit Finance. With that refactor HHL moved to Qiskit Terra.

So this change would only be in Qiskit Terra. 
@Cryoris  Could you please tell me where the tests for HHL are? I cant seem to find them
Sure, they're in https://github.com/Qiskit/qiskit-terra/blob/main/test/python/algorithms/test_linear_solvers.py 🙂 

Resolving patch:
diff --git a/qiskit/algorithms/linear_solvers/hhl.py b/qiskit/algorithms/linear_solvers/hhl.py
--- a/qiskit/algorithms/linear_solvers/hhl.py
+++ b/qiskit/algorithms/linear_solvers/hhl.py
@@ -307,7 +307,9 @@ def _calculate_observable(
         return result, expectation_results
 
     def construct_circuit(
-        self, matrix: Union[np.ndarray, QuantumCircuit], vector: Union[np.ndarray, QuantumCircuit]
+        self,
+        matrix: Union[List, np.ndarray, QuantumCircuit],
+        vector: Union[List, np.ndarray, QuantumCircuit],
     ) -> QuantumCircuit:
         """Construct the HHL circuit.
 
@@ -326,7 +328,9 @@ def construct_circuit(
         if isinstance(vector, QuantumCircuit):
             nb = vector.num_qubits
             vector_circuit = vector
-        elif isinstance(vector, np.ndarray):
+        elif isinstance(vector, (list, np.ndarray)):
+            if isinstance(list):
+                vector = np.array(vector)
             nb = int(np.log2(len(vector)))
             vector_circuit = QuantumCircuit(nb)
             vector_circuit.isometry(vector / np.linalg.norm(vector), list(range(nb)), None)
@@ -469,8 +473,8 @@ def construct_circuit(
 
     def solve(
         self,
-        matrix: Union[np.ndarray, QuantumCircuit],
-        vector: Union[np.ndarray, QuantumCircuit],
+        matrix: Union[List, np.ndarray, QuantumCircuit],
+        vector: Union[List, np.ndarray, QuantumCircuit],
         observable: Optional[
             Union[
                 LinearSystemObservable,


Test patch:
diff --git a/test/python/algorithms/test_linear_solvers.py b/test/python/algorithms/test_linear_solvers.py
--- a/test/python/algorithms/test_linear_solvers.py
+++ b/test/python/algorithms/test_linear_solvers.py
@@ -224,6 +224,16 @@ class TestLinearSolver(QiskitAlgorithmsTestCase):
                 [1.0, -2.1, 3.2, -4.3],
                 MatrixFunctional(1, 1 / 2),
             ],
+            [
+                [
+                    [1 / 2, 1 / 6, 0, 0],
+                    [1 / 6, 1 / 2, 1 / 6, 0],
+                    [0, 1 / 6, 1 / 2, 1 / 6],
+                    [0, 0, 1 / 6, 1 / 2],
+                ],
+                [1.0, -2.1, 3.2, -4.3],
+                MatrixFunctional(1, 1 / 2),
+            ],
             [
                 TridiagonalToeplitz(3, 1, -1 / 2, trotter_steps=2),
                 [-9 / 4, -0.3, 8 / 7, 10, -5, 11.1, 13 / 11, -27 / 12],
@@ -236,8 +246,10 @@ def test_hhl(self, matrix, right_hand_side, observable):
         """Test the HHL class."""
         if isinstance(matrix, QuantumCircuit):
             num_qubits = matrix.num_state_qubits
-        elif isinstance(matrix, np.ndarray):
+        elif isinstance(matrix, (np.ndarray)):
             num_qubits = int(np.log2(matrix.shape[0]))
+        elif isinstance(matrix, list):
+            num_qubits = int(np.log2(len(matrix)))
 
         rhs = right_hand_side / np.linalg.norm(right_hand_side)
 
@@ -252,7 +264,9 @@ def test_hhl(self, matrix, right_hand_side, observable):
         # Calculate analytical value
         if isinstance(matrix, QuantumCircuit):
             exact_x = np.dot(np.linalg.inv(matrix.matrix), rhs)
-        elif isinstance(matrix, np.ndarray):
+        elif isinstance(matrix, (list, np.ndarray)):
+            if isinstance(matrix, list):
+                matrix = np.array(matrix)
             exact_x = np.dot(np.linalg.inv(matrix), rhs)
         exact_result = observable.evaluate_classically(exact_x)