Permalink
Browse files

test for (and fix) multiple trailing newlines

  • Loading branch information...
1 parent 2645659 commit 38bc9ea2f5b85aa923eca16a6ea40808557df74a @smichr smichr committed May 15, 2012
View
@@ -50,4 +50,3 @@
},
ext_modules = extensions
)
-
@@ -67,7 +67,7 @@ def _str_member_list(self, name):
if prefix:
prefix = '~%s.' % prefix
-
+
## Lines that are commented out are used to make the
## autosummary:: table. Since SymPy does not use the
## autosummary:: functionality, it is easiest to just comment it
View
@@ -167,4 +167,3 @@ def run(self):
return base_directive.run(self)
return directive
-
@@ -14,13 +14,13 @@
vars = symbols('t x y z')
gamma_t,gamma_x,gamma_y,gamma_z = MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)
-
+
m,e = symbols('m e')
Format('1 1 1 1')
I = MV(ONE,'pseudo')
nvars = len(vars)
psi = MV('psi','spinor',fct=True)
- A = MV('A','vector',fct=True)
+ A = MV('A','vector',fct=True)
sig_x = gamma_x*gamma_t
sig_y = gamma_y*gamma_t
sig_z = gamma_z*gamma_t
@@ -36,4 +36,3 @@
Format('mv=3')
print r'\nabla \bm{\psi} I \sigma_{z}-eA\bm{\psi}-m\bm{\psi}\gamma_{t} = ',dirac_eq,' = 0'
xdvi(filename='Dirac.tex')
-
@@ -4,7 +4,7 @@
from sympy.galgebra.latex_ex import *
if __name__ == '__main__':
-
+
metric = '1 0 0 0,'+\
'0 -1 0 0,'+\
'0 0 -1 0,'+\
@@ -44,12 +44,3 @@
print 'Curl $E$ and Div $B$ equations'
print '<\\nabla F>_3 =',gradF.project(3),' = 0'
xdvi(filename='Maxwell.tex')
-
-
-
-
-
-
-
-
-
@@ -44,4 +44,3 @@
Plane through a, b, and d
Plane : A^B^n^D^X = 0 = {1/2 - x0/2 - x1/2 - x2/2}e0^e1^e2^n^nbar
-
@@ -28,19 +28,19 @@
dpsi = psi.grad()
print 'Gradient of Scalar Function $\\psi$'
print '\\nabla\\psi =',dpsi
-
+
#A = MV.vector_fct('A')
A = MV('A','vector',fct=True)
#A.name = 'A'
print 'Div and Curl of Vector Function $A$'
print A
-
+
gradA = A.grad()
I = MV(ONE,'pseudo')
divA = A.grad_int()
curlA = -I*A.grad_ext()
print '\\nabla \\cdot A =',divA
Format('mv=3')
print '-I\\lp\\nabla \\W A\\rp =',curlA
-
+
xdvi(filename='coords.tex')
@@ -69,7 +69,7 @@
print 'W =',W
W = collect(W,[C,C**2],evaluate=False)
print 'W =',W
-
+
a = W[C**2]
b = W[C]
c = W[ONE]
@@ -100,35 +100,35 @@
+{-(Y.e)*Binv*s}X^e
+{(X.e)*Binv*s}Y^e
-R*X*R.rev() = {Binv*(2*(X.Y)*c*s - 2*(X.e)*(Y.e)*c*s) + Binv**2*((X.Y)**2*s**2
+R*X*R.rev() = {Binv*(2*(X.Y)*c*s - 2*(X.e)*(Y.e)*c*s) + Binv**2*((X.Y)**2*s**2
- 2*(X.Y)*(X.e)*(Y.e)*s**2) + c**2}X
+{2*Binv*c*s*(X.e)**2}Y
+{Binv**2*(-2*(X.e)*(X.Y)**2*s**2 + 4*(X.Y)*(Y.e)*(X.e)**2*s**2)
- 2*(X.Y)*(X.e)*Binv*c*s}e
-(R*X*rev(R)).Y = {Binv*s*(-4*(X.Y)*(X.e)*(Y.e)*c + 2*c*(X.Y)**2)
+(R*X*rev(R)).Y = {Binv*s*(-4*(X.Y)*(X.e)*(Y.e)*c + 2*c*(X.Y)**2)
+ Binv**2*s**2*(-4*(X.e)*(Y.e)*(X.Y)**2 +
4*(X.Y)*(X.e)**2*(Y.e)**2 + (X.Y)**3) + (X.Y)*c**2}1
-(R*X*R.rev()).Y = S*(-2*(X.Y)*(X.e)*(Y.e) + (X.Y)**2)**(1/2)
- + (X.Y)*Binv*C*(-2*(X.Y)*(X.e)*(Y.e) +
- (X.Y)**2)**(1/2) + (X.e)*(Y.e)*Binv*(-2*(X.Y)*(X.e)*(Y.e)
- + (X.Y)**2)**(1/2) -
+(R*X*R.rev()).Y = S*(-2*(X.Y)*(X.e)*(Y.e) + (X.Y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C**2 -
2*C*(X.e)**2*(Y.e)**2
W = {1: -2*(X.Y)*(X.e)*(Y.e) + (X.Y)**2 + (X.e)**2*(Y.e)**2,
@@ -76,4 +76,3 @@
(E1|e1)/E^2 = 1
(E2|e2)/E^2 = 1
(E3|e3)/E^2 = 1
-
@@ -5,9 +5,9 @@
tex.Format()
xbm,alpha_1,delta__nugamma_r = sympy.symbols('xbm alpha_1 delta__nugamma_r')
-
+
x = alpha_1*xbm/delta__nugamma_r
-
+
print 'x =',x
-
+
tex.xdvi()
@@ -165,4 +165,3 @@ def main():
if __name__ == "__main__":
main()
-
View
@@ -1,3 +1,3 @@
import setuptools
-execfile('setup.py')
+execfile('setup.py')
View
@@ -328,4 +328,3 @@ def rotate(th):
rv[1, 0] = -s
rv[2, 2] = 1
return rv
-
@@ -2196,4 +2196,3 @@ def _sas(l1, d, l2):
p2 = Point(l1, 0)
p3 = p2 + Point(cos(rad(d))*l2, sin(rad(d))*l2)
return Triangle(p1, p2, p3)
-
@@ -39,6 +39,7 @@
message_gen_raise = "File contains generic exception: %s, line %s"
message_old_raise = "File contains old-style raise statement: %s, line %s, \"%s\""
message_eof = "File does not end with a newline: %s, line %s"
+message_multi_eof = "File ends with more than 1 newline: %s, line %s"
implicit_test_re = re.compile('^\s*(>>> )?(\.\.\. )?from .* import .*\*')
str_raise_re = re.compile(r'^\s*(>>> )?(\.\.\. )?raise(\s+(\'|\")|\s*(\(\s*)+(\'|\"))')
@@ -76,7 +77,7 @@ def test_files():
o no lines contains a trailing whitespace
o no lines end with \r\n
o no line uses tabs instead of spaces
- o that the file ends with a newline
+ o that the file ends with a single newline
o there are no general or string exceptions
o there are no old style raise statements
"""
@@ -111,9 +112,12 @@ def test_this_file(fname, test_file):
if result is not None:
assert False, message_old_raise % (fname, idx+1, result.group(2))
- if line is not None and not line.endswith('\n'):
- # eof newline check
- assert False, message_eof % (fname, idx+1)
+ if line is not None:
+ if line == '\n' and idx > 0:
+ assert False, message_multi_eof % (fname, idx+1)
+ elif not line.endswith('\n'):
+ # eof newline check
+ assert False, message_eof % (fname, idx+1)
exclude = set([
"%(sep)smpmath%(sep)s" % sepd,

0 comments on commit 38bc9ea

Please sign in to comment.