Ville
Ville

Reputation: 3

Python: Syntax error, invalid syntax, array edit

I'm trying to implement the following code, but keep receiving a syntax error on the last line of the code. However I can't find the mistake. In my view it works exactly the same as the code before. Thanks a lot for any help!

import numpy as np
import matplotlib.pyplot as plt
N=100
D=2

X=np.random.randn(N,D)

#Center first 50 points at (-2,-2)'
X[:50,:] =X[:50,:] - 2 * np.ones((50,D))

#Center last 50 points at 2,2
X=[50:,:]=X[50:,:] + 2 * np.ones((50,D))

Upvotes: 0

Views: 1280

Answers (2)

user15051990
user15051990

Reputation: 1905

Try this out:

import numpy as np
import matplotlib.pyplot as plt
N=100
D=2

X=np.random.randn(N,D)

#Center first 50 points at (-2,-2)'
X[:50,:] =X[:50,:] - 2 * np.ones((50,D))

# #Center last 50 points at 2,2
X[50:,:]=X[50:,:] + 2 * np.ones((50,D))

Upvotes: 0

RVA92
RVA92

Reputation: 736

You have a "=" to much at the last line.

X[50:,:]=X[50:,:] + 2 * np.ones((50,D))

Upvotes: 1

Related Questions