0

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))
3
  • Can you add the exact text of the error to your question? Commented Feb 26, 2019 at 14:45
  • 3
    Can you spot there error here? X=[50:,:]=X[50:,:] Commented Feb 26, 2019 at 14:46
  • Thanks a lot! I don't know how I didn't recognize it before. Commented Feb 26, 2019 at 15:09

2 Answers 2

1

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

X[50:,:]=X[50:,:] + 2 * np.ones((50,D))
Sign up to request clarification or add additional context in comments.

Comments

0

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))

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.