Hi everyone.
I’m nwew to Python so I’m sorry if the question may be silly, but I’m really doing my best.
I’m trying to create a simple script that uses numpy in Python 3 script in GH.
I want to extract the eigenvectors of a 2x2 symmetrical matrix, but GH doesn’t recognize the output as a list of vectors. I think it sees it as a nested list somehow.
I attach the script:
import numpy as np
# Create lists
N1 = []
N2 = []
n1 = []
n2 = []
# Assuming N11, N12, and N22 are already defined lists
for i in range(len(N11)):
# Define 2x2 matrices
N = np.array([[N11[i], N12[i]],
[N12[i], N22[i]]])
# Evaluate eigenvalues and eigenvectors
eigenvalues, eigenvectors = np.linalg.eig(N)
# Append eigenvalues to lists
N1.append(eigenvalues[0].real)
N2.append(eigenvalues[1].real)
# Append eigenvectors to lists
n1.append(eigenvectors[:, 0].real.tolist())
n2.append(eigenvectors[:, 1].real.tolist())
the error that occurs is:
System.Collections.Generic.List’1[System-Object]
instead of a list of vectors.
Do you maybe know how to solve the issue? I know I can extract the components and create vectors then, but I would like to know how to extract the list directly.
Thank you very much