-2

This code snippet

for i,j in np.ndindex(Sigma.shape):
    if i<N+1 and j<N+1:
        Sigma[i,j]=min(itt(i),itt(j))
    elif i>=N+1 and j>=N+1:
        if i==j:
            Sigma[i,j]=itt(i)**(2*H)
        else:
            max_time=max(itt(i),itt(j))
            min_time=min(itt(i),itt(j))
            if min_time != 0:
                Sigma[i,j]=min_time**(2*H)*G(max_time/min_time)
    elif i<N+1 and j>=N+1:
        Sigma[i,j]=rho*D_H*(itt(j)**(H+1/2)-(itt(j)-min(itt(i),itt(j))**(H+1/2))
    elif i>=N+1 and j<N+1:
        Sigma[i,j]=rho*D_H*(itt(i)**(H+1/2)-(itt(i)-min(itt(i),itt(j))**(H+1/2))

raises

elif i>=N+1 and j<N+1:
   ^

SyntaxError: invalid syntax

Earlier this afternoon, I ran into some problems with mixed spaces/tabs which I think I have resolved by now after using Detab/Entab in Textwrangler, at least no indentation errors are raised anymore. I do have the suspicion thought that there is a connection to my problem on the top.

Two-Bit Alchemist
  • 17,966
  • 6
  • 47
  • 82
Ben
  • 465
  • 2
  • 6
  • 17
  • I get that you're frustrated, but "I've been working on this for two hours" and "any help deeply appreciated" and other such noise is totally irrelevant to this. Please only include the information we need to help solve this. Everything else is at best noise, and at worst comes across as begging for privileged help. – Two-Bit Alchemist Nov 25 '15 at 19:02
  • If you use an IDE such as Eclipse these errors will be shown immediately, it really helps. – toti08 Nov 25 '15 at 20:29
  • Does this answer your question? ['Syntax Error: invalid syntax' for no apparent reason](https://stackoverflow.com/questions/24237111/syntax-error-invalid-syntax-for-no-apparent-reason) – user202729 Jan 20 '21 at 14:11

2 Answers2

4

You have unbalanced parens on the previous line.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • 1
    Yep, either use syntax highlighting or count the parens. 9 left, 8 right. Any time there is a syntax error like this on a correct-looking line, this is 99% the case. – Two-Bit Alchemist Nov 25 '15 at 19:04
0

this line has not a parens :

 Sigma[i,j]=rho*D_H*(itt(j)**(H+1/2)-(itt(j)-min(itt(i),itt(j))**(H+1/2))  #")"
Ahmad
  • 35
  • 1
  • 8