1

I have a numpy matrix of size 3X3 and I am trying to insert a list into a matrix. But it gives the following error:

ValueError: setting an array element with a sequence.

The following code is here:

for ind1, var1 in enumerate(combined_edges[0]):
        for ind2, var2 in enumerate(combined_edges[1]):
            t,u, xm,ym,xn,yn,xo,yo,xr,yr, bool = edgeIntersect(var1,var2)
            if bool == False:
                print("There is no intersection")
                intersectMat[ind1][ind2] = 0
            else:
                t = int(t) if np.asscalar(t).is_integer() else t
                u = int(u) if np.asscalar(u).is_integer() else u
                alpha = var1[0].point()[0] + t*(var1[1].point()[0] - var1[0].point()[0])
                beta = var1[0].point()[1] + t*(var1[1].point()[1] - var1[0].point()[1])
                new_node = Node((alpha,beta), mark=True)
                print(new_node.point())
                intersectMat[ind1][ind2] = array(new_node.point(), dtype=int)

Any suggestion ??

2
  • Means exactly what it says, you're trying to cram a sequence of numbers into a single number slot. It can be thrown under various circumstances. stackoverflow.com/questions/4674473/… Commented Jan 24, 2019 at 14:41
  • I did this but it again gives the error. Commented Jan 24, 2019 at 14:45

1 Answer 1

1

Numpy arrays are not like ordinary python lists (or lists of lists; or lists of lists of lists ...). They cannot store sequences at particular addresses.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.