Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1596 from jrioux/codequality

Codequality
  • Loading branch information...
commit 57e94e48839af929eab68454e3dbdc96fe399f6b 2 parents c27dfe6 + 8750d10
Christopher Smith smichr authored
Showing with 4,495 additions and 4,597 deletions.
  1. +1 −1  bin/adapt_paths.py
  2. +116 −101 bin/coverage_doctest.py
  3. +9 −7 bin/coverage_report.py
  4. +2 −2 bin/generate_test_list.py
  5. +2 −2 bin/sympy_time.py
  6. +11 −11 bin/sympy_time_cache.py
  7. +1 −1  bin/test_import.py
  8. +4 −4 build.py
  9. +1 −1  doc/api/conf.py
  10. +35 −31 doc/ext/docscrape.py
  11. +10 −7 doc/ext/docscrape_sphinx.py
  12. +10 −6 doc/ext/numpydoc.py
  13. +15 −17 doc/src/conf.py
  14. +17 −17 doc/src/modules/galgebra/GA/BasicGAtest.py
  15. +11 −11 doc/src/modules/galgebra/GA/Dirac.py
  16. +20 −20 doc/src/modules/galgebra/GA/Maxwell.py
  17. +28 −23 doc/src/modules/galgebra/GA/conformalgeometryGAtest.py
  18. +16 −14 doc/src/modules/galgebra/GA/coords.py
  19. +4 −2 doc/src/modules/galgebra/GA/headerGAtest.py
  20. +107 −107 doc/src/modules/galgebra/GA/hyperbolicGAtest.py
  21. +47 −46 doc/src/modules/galgebra/GA/reciprocalframeGAtest.py
  22. +21 −20 doc/src/modules/galgebra/latex_ex/Maxwell.py
  23. +4 −3 doc/src/modules/galgebra/latex_ex/latexdemo.py
  24. +7 −16 examples/advanced/autowrap_integrators.py
  25. +6 −6 examples/advanced/curvilinear_coordinates.py
  26. +14 −9 examples/advanced/dense_coding_example.py
  27. +156 −160 examples/advanced/fem.py
  28. +6 −6 examples/advanced/gibbs_phenomenon.py
  29. +8 −8 examples/advanced/pidigits.py
  30. +37 −35 examples/advanced/pyglet_plotting.py
  31. +50 −51 examples/advanced/qft.py
  32. +78 −79 examples/advanced/relativity.py
  33. +4 −3 examples/all.py
  34. +8 −8 examples/beginner/limits_examples.py
  35. +11 −11 examples/beginner/plot_examples.py
  36. +32 −32 examples/intermediate/coupled_cluster.py
  37. +2 −2 examples/intermediate/infinite_1d_box.py
  38. +1 −1  examples/intermediate/mplot2d.py
  39. +3 −3 examples/intermediate/mplot3d.py
  40. +23 −25 examples/intermediate/partial_differential_eqs.py
  41. +3 −3 examples/intermediate/sample.py
  42. +3 −3 examples/intermediate/trees.py
  43. +11 −11 examples/intermediate/vandermonde.py
  44. +27 −27 setup.py
  45. +1 −1  sympy/abc.py
  46. +1 −1  sympy/assumptions/ask.py
  47. +1 −1  sympy/assumptions/handlers/calculus.py
  48. +1 −1  sympy/assumptions/handlers/sets.py
  49. +0 −1  sympy/assumptions/tests/__init__.py
  50. +273 −273 sympy/assumptions/tests/test_query.py
  51. +177 −177 sympy/benchmarks/bench_meijerint.py
  52. +12 −12 sympy/benchmarks/bench_symbench.py
  53. +2 −2 sympy/categories/baseclasses.py
  54. +8 −8 sympy/categories/diagram_drawing.py
  55. +2 −2 sympy/categories/tests/test_drawing.py
  56. +14 −12 sympy/combinatorics/generators.py
  57. +2 −2 sympy/combinatorics/graycode.py
  58. +27 −27 sympy/combinatorics/perm_groups.py
  59. +28 −28 sympy/combinatorics/polyhedron.py
  60. +1 −1  sympy/combinatorics/subsets.py
  61. +0 −1  sympy/combinatorics/tests/__init__.py
  62. +6 −6 sympy/combinatorics/tests/test_perm_groups.py
  63. +4 −4 sympy/combinatorics/tests/test_permutations.py
  64. +3 −3 sympy/combinatorics/tests/test_polyhedron.py
  65. +3 −3 sympy/combinatorics/tests/test_util.py
  66. +4 −4 sympy/combinatorics/testutil.py
  67. +1 −1  sympy/concrete/summations.py
  68. +0 −1  sympy/concrete/tests/__init__.py
  69. +3 −3 sympy/concrete/tests/test_gosper.py
  70. +12 −16 sympy/concrete/tests/test_sums_products.py
  71. +3 −3 sympy/core/__init__.py
  72. +1 −1  sympy/core/add.py
  73. +1 −1  sympy/core/core.py
  74. +3 −3 sympy/core/evalf.py
  75. +3 −3 sympy/core/expr.py
  76. +2 −2 sympy/core/exprtools.py
  77. +2 −2 sympy/core/facts.py
  78. +3 −3 sympy/core/function.py
  79. +1 −1  sympy/core/mul.py
  80. +16 −16 sympy/core/numbers.py
  81. +3 −3 sympy/core/power.py
  82. +17 −17 sympy/core/relational.py
  83. +1 −1  sympy/core/sets.py
  84. +2 −2 sympy/core/symbol.py
  85. +0 −1  sympy/core/tests/__init__.py
  86. +25 −24 sympy/core/tests/test_arit.py
  87. +1 −1  sympy/core/tests/test_basic.py
  88. +1 −1  sympy/core/tests/test_complex.py
  89. +1 −1  sympy/core/tests/test_count_ops.py
  90. +1 −1  sympy/core/tests/test_diff.py
  91. +1 −1  sympy/core/tests/test_eval_power.py
  92. +2 −2 sympy/core/tests/test_evalf.py
  93. +38 −40 sympy/core/tests/test_expr.py
  94. +19 −19 sympy/core/tests/test_exprtools.py
  95. +32 −33 sympy/core/tests/test_facts.py
  96. +10 −10 sympy/core/tests/test_function.py
  97. +3 −3 sympy/core/tests/test_logic.py
  98. +1 −1  sympy/core/tests/test_match.py
  99. +6 −6 sympy/core/tests/test_noncommutative.py
  100. +44 −43 sympy/core/tests/test_numbers.py
  101. +61 −60 sympy/core/tests/test_sets.py
  102. +20 −20 sympy/core/tests/test_subs.py
  103. +48 −48 sympy/core/tests/test_symbol.py
  104. +26 −23 sympy/core/tests/test_sympify.py
  105. +28 −28 sympy/diffgeom/diffgeom.py
  106. +1 −1  sympy/diffgeom/rn.py
  107. +0 −1  sympy/diffgeom/tests/__init__.py
  108. +3 −3 sympy/diffgeom/tests/test_function_diffgeom_book.py
  109. +0 −1  sympy/external/tests/__init__.py
  110. +8 −13 sympy/external/tests/test_autowrap.py
  111. +26 −31 sympy/external/tests/test_codegen.py
  112. +8 −8 sympy/external/tests/test_numpy.py
  113. +0 −1  sympy/functions/combinatorial/tests/__init__.py
  114. +3 −3 sympy/functions/combinatorial/tests/test_comb_numbers.py
  115. +5 −5 sympy/functions/elementary/complexes.py
  116. +1 −1  sympy/functions/elementary/exponential.py
  117. +3 −3 sympy/functions/elementary/piecewise.py
  118. +0 −1  sympy/functions/elementary/tests/__init__.py
  119. +12 −12 sympy/functions/elementary/tests/test_complexes.py
  120. +10 −10 sympy/functions/elementary/tests/test_hyperbolic.py
  121. +1 −1  sympy/functions/elementary/tests/test_integers.py
  122. +6 −6 sympy/functions/elementary/tests/test_miscellaneous.py
  123. +1 −1  sympy/functions/elementary/tests/test_piecewise.py
  124. +10 −10 sympy/functions/elementary/tests/test_trigonometric.py
  125. +7 −8 sympy/functions/elementary/trigonometric.py
  126. +2 −2 sympy/functions/special/bessel.py
  127. +1 −2  sympy/functions/special/delta_functions.py
  128. +4 −4 sympy/functions/special/error_functions.py
  129. +2 −2 sympy/functions/special/gamma_functions.py
  130. +10 −10 sympy/functions/special/hyper.py
  131. +2 −2 sympy/functions/special/polynomials.py
  132. +5 −5 sympy/functions/special/spherical_harmonics.py
  133. +2 −2 sympy/functions/special/tensor_functions.py
  134. +0 −1  sympy/functions/special/tests/__init__.py
  135. +10 −10 sympy/functions/special/tests/test_bessel.py
  136. +70 −68 sympy/functions/special/tests/test_error_functions.py
  137. +37 −37 sympy/functions/special/tests/test_gamma_functions.py
  138. +24 −24 sympy/functions/special/tests/test_hyper.py
  139. +26 −24 sympy/functions/special/tests/test_spec_polynomials.py
  140. +3 −3 sympy/functions/special/tests/test_spherical_harmonics.py
  141. +1 −1  sympy/functions/special/zeta_functions.py
  142. +26 −26 sympy/galgebra/GA.py
  143. +4 −4 sympy/galgebra/examples/Dirac.py
  144. +3 −3 sympy/galgebra/examples/Maxwell.py
  145. +2 −2 sympy/galgebra/examples/coords.py
  146. +32 −34 sympy/galgebra/latex_ex.py
  147. +0 −1  sympy/galgebra/tests/__init__.py
  148. +40 −38 sympy/galgebra/tests/test_GA.py
  149. +3 −4 sympy/geometry/ellipse.py
  150. +2 −2 sympy/geometry/line.py
  151. +9 −9 sympy/geometry/polygon.py
  152. +0 −1  sympy/geometry/tests/__init__.py
  153. +60 −61 sympy/geometry/tests/test_geometry.py
  154. +4 −4 sympy/integrals/integrals.py
  155. +35 −35 sympy/integrals/meijerint.py
  156. +1 −2  sympy/integrals/rationaltools.py
  157. +0 −1  sympy/integrals/tests/__init__.py
  158. +77 −81 sympy/integrals/tests/test_integrals.py
  159. +81 −83 sympy/integrals/tests/test_meijerint.py
  160. +7 −7 sympy/integrals/tests/test_risch.py
  161. +129 −132 sympy/integrals/tests/test_transforms.py
  162. +17 −19 sympy/integrals/tests/test_trigonometry.py
  163. +13 −13 sympy/integrals/transforms.py
  164. +12 −12 sympy/integrals/trigonometry.py
  165. +0 −1  sympy/logic/algorithms/__init__.py
  166. +1 −1  sympy/logic/boolalg.py
  167. +0 −1  sympy/logic/tests/__init__.py
  168. +16 −16 sympy/logic/tests/test_boolalg.py
  169. +1 −1  sympy/logic/tests/test_inference.py
  170. +3 −3 sympy/matrices/dense.py
  171. +2 −2 sympy/matrices/expressions/blockmatrix.py
  172. +0 −1  sympy/matrices/expressions/tests/__init__.py
  173. +1 −1  sympy/matrices/expressions/tests/test_matrix_exprs.py
  174. +9 −8 sympy/matrices/matrices.py
  175. +0 −1  sympy/matrices/tests/__init__.py
  176. +1 −1  sympy/matrices/tests/test_immutable.py
  177. +1 −1  sympy/matrices/tests/test_interactions.py
  178. +158 −161 sympy/matrices/tests/test_matrices.py
  179. +102 −101 sympy/matrices/tests/test_sparse.py
  180. +3 −3 sympy/ntheory/__init__.py
  181. +37 −79 sympy/ntheory/factor_.py
  182. +1 −1  sympy/ntheory/partitions_.py
  183. +1 −1  sympy/ntheory/primetest.py
  184. +0 −1  sympy/ntheory/tests/__init__.py
  185. +5 −5 sympy/ntheory/tests/test_ntheory.py
  186. +3 −3 sympy/parsing/ast_parser.py
  187. +1 −1  sympy/parsing/ast_parser_python25.py
  188. +15 −15 sympy/parsing/maxima.py
  189. +7 −7 sympy/parsing/sympy_parser.py
  190. +3 −3 sympy/parsing/sympy_tokenize.py
  191. +0 −1  sympy/parsing/tests/__init__.py
  192. +9 −11 sympy/parsing/tests/test_maxima.py
  193. +3 −3 sympy/physics/gaussopt.py
  194. +29 −29 sympy/physics/matrices.py
  195. +4 −4 sympy/physics/mechanics/essential.py
  196. +1 −1  sympy/physics/mechanics/kane.py
  197. +0 −1  sympy/physics/mechanics/tests/__init__.py
  198. +18 −18 sympy/physics/mechanics/tests/test_functions.py
  199. +4 −4 sympy/physics/mechanics/tests/test_kane.py
  200. +3 −3 sympy/physics/quantum/cg.py
  201. +2 −4 sympy/physics/quantum/circuitutils.py
  202. +1 −1  sympy/physics/quantum/density.py
  203. +9 −10 sympy/physics/quantum/gate.py
  204. +5 −5 sympy/physics/quantum/grover.py
  205. +9 −9 sympy/physics/quantum/hilbert.py
  206. +6 −14 sympy/physics/quantum/identitysearch.py
  207. +1 −1  sympy/physics/quantum/matrixutils.py
  208. +1 −1  sympy/physics/quantum/operator.py
  209. +1 −1  sympy/physics/quantum/qapply.py
  210. +3 −3 sympy/physics/quantum/qexpr.py
  211. +3 −3 sympy/physics/quantum/qubit.py
  212. +1 −1  sympy/physics/quantum/shor.py
  213. +4 −4 sympy/physics/quantum/spin.py
  214. +4 −4 sympy/physics/quantum/state.py
  215. +0 −1  sympy/physics/quantum/tests/__init__.py
  216. +5 −5 sympy/physics/quantum/tests/test_cartesian.py
  217. +1 −1  sympy/physics/quantum/tests/test_circuitutils.py
  218. +1 −1  sympy/physics/quantum/tests/test_commutator.py
  219. +9 −7 sympy/physics/quantum/tests/test_density.py
  220. +3 −3 sympy/physics/quantum/tests/test_gate.py
  221. +6 −7 sympy/physics/quantum/tests/test_identitysearch.py
  222. +7 −7 sympy/physics/quantum/tests/test_operator.py
  223. +1 −1  sympy/physics/quantum/tests/test_qexpr.py
  224. +12 −9 sympy/physics/quantum/tests/test_qft.py
  225. +29 −33 sympy/physics/quantum/tests/test_qubit.py
  226. +143 −135 sympy/physics/quantum/tests/test_spin.py
  227. +1 −1  sympy/physics/quantum/tests/test_state.py
  228. +1 −1  sympy/physics/quantum/tests/test_tensorproduct.py
  229. +17 −17 sympy/physics/secondquant.py
  230. +1 −1  sympy/physics/sho.py
  231. +0 −1  sympy/physics/tests/__init__.py
  232. +1 −1  sympy/physics/tests/test_gaussopt.py
  233. +19 −21 sympy/physics/tests/test_hydrogen.py
  234. +4 −4 sympy/physics/tests/test_qho_1d.py
  235. +167 −167 sympy/physics/tests/test_secondquant.py
  236. +16 −16 sympy/physics/wigner.py
  237. +1 −1  sympy/plotting/__init__.py
  238. +80 −97 sympy/plotting/experimental_lambdify.py
  239. +2 −2 sympy/plotting/intervalmath/__init__.py
  240. +4 −4 sympy/plotting/intervalmath/lib_interval.py
  241. +18 −25 sympy/plotting/plot.py
  242. +2 −2 sympy/plotting/plot_implicit.py
  243. +2 −2 sympy/plotting/pygletplot/color_scheme.py
  244. +1 −1  sympy/plotting/pygletplot/plot.py
  245. +2 −2 sympy/plotting/pygletplot/plot_camera.py
  246. +68 −68 sympy/plotting/pygletplot/plot_controller.py
  247. +5 −5 sympy/plotting/pygletplot/plot_mode.py
  248. +1 −1  sympy/plotting/pygletplot/plot_surface.py
  249. +2 −2 sympy/plotting/pygletplot/tests/test_plotting.py
  250. +0 −1  sympy/plotting/tests/__init__.py
  251. +3 −3 sympy/plotting/tests/test_plot.py
  252. +1 −1  sympy/plotting/tests/test_plot_implicit.py
  253. +1 −1  sympy/polys/agca/ideals.py
  254. +11 −11 sympy/polys/agca/modules.py
  255. +3 −3 sympy/polys/agca/tests/test_ideals.py
  256. +7 −7 sympy/polys/agca/tests/test_modules.py
  257. +2 −2 sympy/polys/distributedmodules.py
  258. +3 −3 sympy/polys/distributedpolys.py
  259. +2 −2 sympy/polys/domains/mpmathrealdomain.py
  260. +2 −2 sympy/polys/domains/polynomialring.py
  261. +1 −1  sympy/polys/domains/ring.py
  262. +2 −2 sympy/polys/domains/sympyrationalfield.py
  263. +1 −1  sympy/polys/euclidtools.py
  264. +1 −1  sympy/polys/factortools.py
  265. +5 −5 sympy/polys/galoistools.py
  266. +3 −3 sympy/polys/polyclasses.py
  267. +1 −1  sympy/polys/polytools.py
  268. +17 −17 sympy/polys/rootisolation.py
  269. +2 −2 sympy/polys/specialpolys.py
  270. +0 −1  sympy/polys/tests/__init__.py
  271. +12 −12 sympy/polys/tests/test_densearith.py
  272. +1 −1  sympy/polys/tests/test_densetools.py
  273. +4 −4 sympy/polys/tests/test_distributedmodules.py
  274. +3 −3 sympy/polys/tests/test_distributedpolys.py
  275. +88 −97 sympy/polys/tests/test_euclidtools.py
  276. +30 −30 sympy/polys/tests/test_factortools.py
  277. +18 −18 sympy/polys/tests/test_galoistools.py
  278. +19 −19 sympy/polys/tests/test_groebnertools.py
  279. +4 −4 sympy/polys/tests/test_monomialtools.py
  280. +7 −7 sympy/polys/tests/test_numberfields.py
  281. +14 −13 sympy/polys/tests/test_partfrac.py
  282. +4 −4 sympy/polys/tests/test_polyclasses.py
  283. +1 −2  sympy/polys/tests/test_polynomialring.py
  284. +41 −41 sympy/polys/tests/test_polyroots.py
  285. +21 −21 sympy/polys/tests/test_polytools.py
  286. +1 −1  sympy/polys/tests/test_rationaltools.py
  287. +100 −103 sympy/polys/tests/test_rootisolation.py
  288. +5 −5 sympy/polys/tests/test_rootoftools.py
  289. +5 −5 sympy/printing/ccode.py
  290. +1 −1  sympy/printing/codeprinter.py
  291. +6 −6 sympy/printing/fcode.py
  292. +15 −15 sympy/printing/jscode.py
  293. +17 −17 sympy/printing/latex.py
  294. +6 −6 sympy/printing/pretty/pretty.py
  295. +3 −3 sympy/printing/pretty/stringpict.py
  296. +0 −1  sympy/printing/pretty/tests/__init__.py
  297. +18 −18 sympy/printing/pretty/tests/test_pretty.py
  298. +1 −1  sympy/printing/preview.py
  299. +1 −1  sympy/printing/str.py
  300. +2 −2 sympy/printing/tableform.py
Sorry, we could not display the entire diff because too many files (366) changed.
2  bin/adapt_paths.py
View
@@ -33,7 +33,7 @@ def fix_file(filename):
# print differences in an unified diff format
d = difflib.unified_diff(orig.split("\n"), s.split("\n"),
- fromfile=filename, tofile=filename+".new", lineterm="")
+ fromfile=filename, tofile=filename + ".new", lineterm="")
import sys
for l in d:
print l
217 bin/coverage_doctest.py
View
@@ -26,22 +26,23 @@
# Load color templates, used from sympy/utilities/runtests.py
color_templates = (
- ("Black" , "0;30"),
- ("Red" , "0;31"),
- ("Green" , "0;32"),
- ("Brown" , "0;33"),
- ("Blue" , "0;34"),
- ("Purple" , "0;35"),
- ("Cyan" , "0;36"),
- ("LightGray" , "0;37"),
- ("DarkGray" , "1;30"),
- ("LightRed" , "1;31"),
- ("LightGreen" , "1;32"),
- ("Yellow" , "1;33"),
- ("LightBlue" , "1;34"),
- ("LightPurple" , "1;35"),
- ("LightCyan" , "1;36"),
- ("White" , "1;37"), )
+ ("Black", "0;30"),
+ ("Red", "0;31"),
+ ("Green", "0;32"),
+ ("Brown", "0;33"),
+ ("Blue", "0;34"),
+ ("Purple", "0;35"),
+ ("Cyan", "0;36"),
+ ("LightGray", "0;37"),
+ ("DarkGray", "1;30"),
+ ("LightRed", "1;31"),
+ ("LightGreen", "1;32"),
+ ("Yellow", "1;33"),
+ ("LightBlue", "1;34"),
+ ("LightPurple", "1;35"),
+ ("LightCyan", "1;36"),
+ ("White", "1;37"),
+)
colors = {}
@@ -52,27 +53,26 @@
def print_header(name, underline=None, overline=None):
- print
- print name
- if underline: print underline*len(name)
+ print
+ print name
+ if underline:
+ print underline*len(name)
def print_coverage(module_path, c, c_md, c_mdt, c_idt, f, f_md, f_mdt, f_idt, score, total_doctests, total_members, verbose=False, no_color=False):
""" Prints details (depending on verbose) of a module """
if no_color:
- score_string = "%s%% (%s of %s)" % (score, total_doctests, \
+ score_string = "%s%% (%s of %s)" % (score, total_doctests,
total_members)
elif score < 100:
- score_string = "%s%s%% (%s of %s)%s" % (c_color % (colors["Red"]) \
- , score , total_doctests, total_members, c_normal)
+ score_string = "%s%s%% (%s of %s)%s" % (c_color % (colors["Red"]), score, total_doctests, total_members, c_normal)
else:
- score_string = "%s%s%% (%s of %s)%s" % (c_color % (colors["Green"]) \
- , score , total_doctests, total_members, c_normal)
+ score_string = "%s%s%% (%s of %s)%s" % (c_color % (colors["Green"]), score, total_doctests, total_members, c_normal)
if verbose:
- print '\n'+'-'*70
+ print '\n' + '-'*70
print module_path
print '-'*70
else:
@@ -85,58 +85,56 @@ def print_coverage(module_path, c, c_md, c_mdt, c_idt, f, f_md, f_mdt, f_idt, sc
else:
if c_md:
- print_header('Missing docstrings','-')
+ print_header('Missing docstrings', '-')
for md in c_md:
- print ' * '+md
+ print ' * ' + md
if c_mdt:
- print_header('Missing doctests','-')
+ print_header('Missing doctests', '-')
for md in c_mdt:
- print ' * '+md
+ print ' * ' + md
if c_idt:
# Use "# indirect doctest" in the docstring to
# supress this warning.
print_header('Indirect doctests', '-')
for md in c_idt:
- print ' * '+md
+ print ' * ' + md
print '\n Use \"# indirect doctest\" in the docstring to supress this warning'
-
- print_header('FUNCTIONS','*')
+ print_header('FUNCTIONS', '*')
if not f:
print_header('No functions found!')
else:
if f_md:
print_header('Missing docstrings', '-')
for md in f_md:
- print ' * '+md
+ print ' * ' + md
if f_mdt:
print_header('Missing doctests', '-')
for md in f_mdt:
- print ' * '+md
+ print ' * ' + md
if f_idt:
print_header('Indirect doctests', '-')
for md in f_idt:
- print ' * '+md
+ print ' * ' + md
print '\n Use \"# indirect doctest\" in the docstring to supress this warning'
-
if verbose:
- print '\n'+'-'*70
+ print '\n' + '-'*70
print "SCORE: %s" % (score_string)
print '-'*70
def _is_indirect(member, doc):
- """ Given string repr of doc and member checks if the member
- contains indirect documentation """
+ """ Given string repr of doc and member checks if the member
+ contains indirect documentation """
- d = member in doc
- e = 'indirect doctest' in doc
- if not d and not e:
- return True
- else:
- return False
+ d = member in doc
+ e = 'indirect doctest' in doc
+ if not d and not e:
+ return True
+ else:
+ return False
def _get_arg_list(name, fobj):
@@ -150,7 +148,8 @@ def _get_arg_list(name, fobj):
arg_list = []
if argspec.args:
- for arg in argspec.args: arg_list.append(str(arg))
+ for arg in argspec.args:
+ arg_list.append(str(arg))
arg_list.reverse()
@@ -165,9 +164,9 @@ def _get_arg_list(name, fobj):
# Add var args
if argspec.varargs:
- arg_list.append(argspec.varargs)
+ arg_list.append(argspec.varargs)
if argspec.keywords:
- arg_list.append(argspec.keywords)
+ arg_list.append(argspec.keywords)
# Truncate long arguments
arg_list = map(lambda x: x[:trunc], arg_list)
@@ -191,20 +190,21 @@ def get_mod_name(path, base):
file_module = ""
h, t = os.path.split(rel_path)
while h or t:
- if t: file_module = t + '.' + file_module
+ if t:
+ file_module = t + '.' + file_module
h, t = os.path.split(h)
return file_module[:-1]
-
def process_function(name, c_name, b_obj, mod_path, f_sk, f_md, f_mdt, f_idt, f_has_doctest, sk_list):
""" Processes a function to get information regarding documentation.
It is assume that the function calling this subrouting has already
verified that it is a valid module function """
- if name in sk_list: return False, False
+ if name in sk_list:
+ return False, False
# We add in the end, as inspect.getsourcelines is slow
add_md = False
@@ -223,15 +223,17 @@ def process_function(name, c_name, b_obj, mod_path, f_sk, f_md, f_mdt, f_idt, f_
full_name = _get_arg_list(c_name + '.' + name, obj)
else:
full_name = _get_arg_list(name, obj)
- if name.startswith('_'): f_sk.append(full_name)
+ if name.startswith('_'):
+ f_sk.append(full_name)
else:
if not obj.__doc__:
add_md = True
elif not '>>>' in obj.__doc__:
add_mdt = True
elif _is_indirect(name, obj.__doc__):
- add_idt = True
- else: f_doctest = True
+ add_idt = True
+ else:
+ f_doctest = True
function = True
@@ -245,9 +247,12 @@ def process_function(name, c_name, b_obj, mod_path, f_sk, f_md, f_mdt, f_idt, f_
return False, False
full_name = "LINE %d: %s" % (line_no, full_name)
- if add_md: f_md.append(full_name)
- elif add_mdt: f_mdt.append(full_name)
- elif add_idt: f_idt.append(full_name)
+ if add_md:
+ f_md.append(full_name)
+ elif add_mdt:
+ f_mdt.append(full_name)
+ elif add_idt:
+ f_idt.append(full_name)
return f_doctest, function
@@ -267,20 +272,22 @@ def process_class(c_name, obj, c_sk, c_md, c_mdt, c_idt, c_has_doctest):
c_dt = False
# Get the line number of class
try:
- source, line_no = inspect.getsourcelines(obj)
+ source, line_no = inspect.getsourcelines(obj)
except IOError:
- # Raised when source does not exist
- # which means the class is not there.
- return False, False, None
+ # Raised when source does not exist
+ # which means the class is not there.
+ return False, False, None
c = True
full_name = "LINE %d: %s" % (line_no, c_name)
- if not obj.__doc__: c_md.append(full_name)
- elif not '>>>' in obj.__doc__: c_mdt.append(full_name)
+ if not obj.__doc__:
+ c_md.append(full_name)
+ elif not '>>>' in obj.__doc__:
+ c_mdt.append(full_name)
elif _is_indirect(c_name, obj.__doc__):
c_idt.append(full_name)
else:
- c_dt = True
+ c_dt = True
c_has_doctest.append(full_name)
return c_dt, c, source
@@ -301,7 +308,6 @@ def coverage(module_path, verbose=False, no_color=False):
print "%s could not be loaded due to %s." % (module_path, repr(a))
return 0, 0
-
c_skipped = []
c_md = []
c_mdt = []
@@ -326,7 +332,8 @@ def coverage(module_path, verbose=False, no_color=False):
# Check for skipped functions first, they throw nasty errors
# when combined with getattr
- if member in skip_members: continue
+ if member in skip_members:
+ continue
# Identify if the member (class/def) a part of this module
obj = getattr(m, member)
@@ -334,31 +341,38 @@ def coverage(module_path, verbose=False, no_color=False):
# Function not a part of this module
if not obj_mod or not obj_mod.__name__ == module_path:
- continue
+ continue
# If it's a function
if inspect.isfunction(obj) or inspect.ismethod(obj):
- f_dt, f = process_function(member, '', obj, module_path, f_skipped, f_md, f_mdt, f_idt, f_has_doctest, skip_members)
- if f: functions += 1
- if f_dt: f_doctests += 1
+ f_dt, f = process_function(member, '', obj, module_path, f_skipped, f_md, f_mdt, f_idt, f_has_doctest, skip_members)
+ if f:
+ functions += 1
+ if f_dt:
+ f_doctests += 1
# If it's a class, look at it's methods too
elif inspect.isclass(obj):
# Process the class first
c_dt, c, source = process_class(member, obj, c_skipped, c_md, c_mdt, c_idt, c_has_doctest)
- if not c: continue
- else: classes += 1
- if c_dt: c_doctests += 1
+ if not c:
+ continue
+ else:
+ classes += 1
+ if c_dt:
+ c_doctests += 1
# Iterate through it's members
for f_name in obj.__dict__:
- if f_name in skip_members or f_name.startswith('_'): continue
+ if f_name in skip_members or f_name.startswith('_'):
+ continue
# Check if def funcname appears in source
- if not ("def "+f_name) in ' '.join(source): continue
+ if not ("def " + f_name) in ' '.join(source):
+ continue
# Identify the module of the current class member
f_obj = getattr(obj, f_name)
@@ -366,35 +380,37 @@ def coverage(module_path, verbose=False, no_color=False):
# Function not a part of this module
if not obj_mod or not obj_mod.__name__ == module_path:
- continue
+ continue
# If it's a function
if inspect.isfunction(f_obj) or inspect.ismethod(f_obj):
- f_dt, f = process_function(f_name, member, obj, module_path, f_skipped, f_md, f_mdt, f_idt, f_has_doctest, skip_members)
- if f: functions += 1
- if f_dt: f_doctests += 1
-
+ f_dt, f = process_function(f_name, member, obj, module_path, f_skipped, f_md, f_mdt, f_idt, f_has_doctest, skip_members)
+ if f:
+ functions += 1
+ if f_dt:
+ f_doctests += 1
# Evaluate the percent coverage
total_doctests = c_doctests + f_doctests
total_members = classes + functions
- if total_members: score = 100 * float(total_doctests) / (total_members)
- else: score = 100
+ if total_members:
+ score = 100 * float(total_doctests) / (total_members)
+ else:
+ score = 100
score = int(score)
# Sort functions/classes by line number
- c_md = sorted(c_md, key = lambda x: int(x.split()[1][:-1]))
- c_mdt = sorted(c_mdt, key = lambda x: int(x.split()[1][:-1]))
- c_idt = sorted(c_idt, key = lambda x: int(x.split()[1][:-1]))
+ c_md = sorted(c_md, key=lambda x: int(x.split()[1][:-1]))
+ c_mdt = sorted(c_mdt, key=lambda x: int(x.split()[1][:-1]))
+ c_idt = sorted(c_idt, key=lambda x: int(x.split()[1][:-1]))
- f_md = sorted(f_md, key = lambda x: int(x.split()[1][:-1]))
- f_mdt = sorted(f_mdt, key = lambda x: int(x.split()[1][:-1]))
- f_idt = sorted(f_idt, key = lambda x: int(x.split()[1][:-1]))
+ f_md = sorted(f_md, key=lambda x: int(x.split()[1][:-1]))
+ f_mdt = sorted(f_mdt, key=lambda x: int(x.split()[1][:-1]))
+ f_idt = sorted(f_idt, key=lambda x: int(x.split()[1][:-1]))
print_coverage(module_path, classes, c_md, c_mdt, c_idt, functions, f_md, f_mdt, f_idt, score, total_doctests, total_members, verbose, no_color)
-
return total_doctests, total_members
def go(sympy_top, file, verbose=False, no_color=False, exact=True):
@@ -402,16 +418,16 @@ def go(sympy_top, file, verbose=False, no_color=False, exact=True):
if os.path.isdir(file):
doctests, num_functions = 0, 0
for F in os.listdir(file):
- _doctests, _num_functions = go(sympy_top, '%s/%s'%(file,F), verbose, no_color, exact=False)
+ _doctests, _num_functions = go(sympy_top, '%s/%s' % (file, F), verbose, no_color, exact=False)
doctests += _doctests
num_functions += _num_functions
return doctests, num_functions
if not (file.endswith('.py') or file.endswith('.pyx')) or \
file.endswith('__init__.py') or \
- not exact and ('test_' in file or 'bench_' in file):
- return 0, 0
+ not exact and ('test_' in file or 'bench_' in file):
+ return 0, 0
if not os.path.exists(file):
- print "File %s does not exist."%file
+ print "File %s does not exist." % file
sys.exit(1)
# Relpath for constructing the module name
@@ -420,18 +436,17 @@ def go(sympy_top, file, verbose=False, no_color=False, exact=True):
if __name__ == "__main__":
-
bintest_dir = os.path.abspath(os.path.dirname(__file__)) # bin/cover...
- sympy_top = os.path.split(bintest_dir)[0] # ../
- sympy_dir = os.path.join(sympy_top, 'sympy') # ../sympy/
+ sympy_top = os.path.split(bintest_dir)[0] # ../
+ sympy_dir = os.path.join(sympy_top, 'sympy') # ../sympy/
if os.path.isdir(sympy_dir):
sys.path.insert(0, sympy_top)
usage = "usage: ./bin/doctest_coverage.py PATH"
parser = OptionParser(
- description = __doc__,
- usage = usage,
+ description=__doc__,
+ usage=usage,
)
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
@@ -460,16 +475,16 @@ def go(sympy_top, file, verbose=False, no_color=False, exact=True):
if options.no_color:
print "TOTAL SCORE for %s: %s%% (%s of %s)" % \
- (get_mod_name(file, sympy_top),score, doctests, num_functions)
+ (get_mod_name(file, sympy_top), score, doctests, num_functions)
elif score < 100:
print "TOTAL SCORE for %s: %s%s%% (%s of %s)%s" % \
- (get_mod_name(file, sympy_top), c_color % (colors["Red"]),\
+ (get_mod_name(file, sympy_top), c_color % (colors["Red"]),
score, doctests, num_functions, c_normal)
else:
print "TOTAL SCORE for %s: %s%s%% (%s of %s)%s" % \
- (get_mod_name(file, sympy_top), c_color % (colors["Green"]),\
+ (get_mod_name(file, sympy_top), c_color % (colors["Green"]),
score, doctests, num_functions, c_normal)
print
16 bin/coverage_report.py
View
@@ -22,7 +22,9 @@
$ bin/coverage_report.py -c
"""
-import os, sys, re
+import os
+import re
+import sys
from optparse import OptionParser
try:
@@ -36,7 +38,7 @@
REPORT_DIR = "covhtml"
REFRESH = False
-omit_dir_patterns= ['.*tests', 'benchmark', 'examples',
+omit_dir_patterns = ['.*tests', 'benchmark', 'examples',
'mpmath', 'pyglet', 'test_external']
omit_dir_re = re.compile(r'|'.join(omit_dir_patterns))
source_re = re.compile(r'.*\.py$')
@@ -54,15 +56,15 @@ def generate_covered_files(top_dir):
def make_report(source_dir, report_dir, use_cache=False):
#code adapted from /bin/test
bin_dir = os.path.abspath(os.path.dirname(__file__)) # bin/
- sympy_top = os.path.split(bin_dir)[0] # ../
- sympy_dir = os.path.join(sympy_top, 'sympy') # ../sympy/
+ sympy_top = os.path.split(bin_dir)[0] # ../
+ sympy_dir = os.path.join(sympy_top, 'sympy') # ../sympy/
if os.path.isdir(sympy_dir):
sys.path.insert(0, sympy_top)
os.chdir(sympy_top)
cov = coverage.coverage()
cov.exclude("raise NotImplementedError")
- cov.exclude("def canonize") #this should be "@decorated"
+ cov.exclude("def canonize") # this should be "@decorated"
cov.exclude("def __mathml__")
if use_cache:
cov.load()
@@ -87,9 +89,9 @@ def make_report(source_dir, report_dir, use_cache=False):
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-c', '--use-cache', action='store_true', default=False,
- help='Use cached data.')
+ help='Use cached data.')
parser.add_option('-d', '--report-dir', default='covhtml',
- help='Directory to put the generated report in.')
+ help='Directory to put the generated report in.')
options, args = parser.parse_args()
4 bin/generate_test_list.py
View
@@ -46,8 +46,8 @@ def get_paths(level=15):
"""
wildcards = ["/"]
for i in range(level):
- wildcards.append(wildcards[-1]+"*/")
- p = ["sympy"+x+"test_*.py" for x in wildcards]
+ wildcards.append(wildcards[-1] + "*/")
+ p = ["sympy" + x + "test_*.py" for x in wildcards]
return p
g = []
4 bin/sympy_time.py
View
@@ -23,7 +23,7 @@ def new_import(name, globals={}, locals={}, fromlist=[]):
level -= 1
parent = old_parent
t2 = time.time()
- elapsed_times[name] = t2-t1
+ elapsed_times[name] = t2 - t1
return module
old_import = __builtins__.__import__
@@ -39,7 +39,7 @@ def new_import(name, globals={}, locals={}, fromlist=[]):
print "== Tree =="
for name, level, parent in import_order:
- print "%s%s: %.3f (%s)" % (" "*level, name, elapsed_times.get(name,0),
+ print "%s%s: %.3f (%s)" % (" "*level, name, elapsed_times.get(name, 0),
parent)
print "\n"
22 bin/sympy_time_cache.py
View
@@ -1,4 +1,5 @@
-import time, timeit
+import time
+import timeit
class TreeNode(object):
def __init__(self, name):
@@ -7,7 +8,7 @@ def __init__(self, name):
self._time = 0
def __str__(self):
- return "%s: %s"%(self._name, self._time)
+ return "%s: %s" % (self._name, self._time)
__repr__ = __str__
@@ -45,12 +46,12 @@ def print_tree(self, level=0, max_depth=None):
if max_depth is not None and max_depth <= level:
return
for child in self.children():
- child.print_tree(level+1, max_depth=max_depth)
+ child.print_tree(level + 1, max_depth=max_depth)
def print_generic(self, n=50, method="time"):
slowest = sorted((getattr(node, method)(), node.name()) for node in self.linearize())[-n:]
for time, name in slowest[::-1]:
- print "%s %s"%(time, name)
+ print "%s %s" % (time, name)
def print_slowest(self, n=50):
self.print_generic(n=50, method="time")
@@ -67,14 +68,14 @@ def write_cachegrind(self, f):
else:
must_close = False
- f.write("fn=%s\n"%self.name())
- f.write("1 %s\n"%self.exclusive_time())
+ f.write("fn=%s\n" % self.name())
+ f.write("1 %s\n" % self.exclusive_time())
counter = 2
for child in self.children():
- f.write("cfn=%s\n"%child.name())
+ f.write("cfn=%s\n" % child.name())
f.write("calls=1 1\n")
- f.write("%s %s\n"%(counter, child.time()))
+ f.write("%s %s\n" % (counter, child.time()))
counter += 1
f.write("\n\n")
@@ -86,7 +87,7 @@ def write_cachegrind(self, f):
f.close()
-pp = TreeNode(None) #We have to use pp since there is a sage function
+pp = TreeNode(None) # We have to use pp since there is a sage function
#called parent that gets imported
seen = set()
@@ -106,8 +107,7 @@ def new_import(name, globals={}, locals={}, fromlist=[]):
t1 = timeit.default_timer()
module = old_import(name, globals, locals, fromlist)
t2 = timeit.default_timer()
- node.set_time(int(1000000*(t2-t1)))
-
+ node.set_time(int(1000000*(t2 - t1)))
pp = old_pp
2  bin/test_import.py
View
@@ -3,5 +3,5 @@
path_hack()
t = clock()
import sympy
-t = clock()-t
+t = clock() - t
print t
8 build.py
View
@@ -40,13 +40,13 @@
)
setup(
- name = "SymPy",
- packages = [
+ name="SymPy",
+ packages=[
"sympy",
"sympy.polys",
],
- cmdclass = {
+ cmdclass={
"build_ext": build_ext
},
- ext_modules = extensions
+ ext_modules=extensions
)
2  doc/api/conf.py
View
@@ -121,7 +121,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [('index', 'sympy.tex', 'SymPy Documentation',
- 'SymPy Development Team', 'manual')]
+ 'SymPy Development Team', 'manual')]
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
66 doc/ext/docscrape.py
View
@@ -20,7 +20,7 @@ def __init__(self, data):
String with lines separated by '\n'.
"""
- if isinstance(data,list):
+ if isinstance(data, list):
self._str = data
else:
self._str = data.split('\n') # store string as list of lines
@@ -58,11 +58,12 @@ def read_to_condition(self, condition_func):
return self[start:self._l]
self._l += 1
if self.eof():
- return self[start:self._l+1]
+ return self[start:self._l + 1]
return []
def read_to_next_empty_line(self):
self.seek_next_non_empty_line()
+
def is_empty(line):
return not line.strip()
return self.read_to_condition(is_empty)
@@ -72,7 +73,7 @@ def is_unindented(line):
return (line.strip() and (len(line.lstrip()) == len(line)))
return self.read_to_condition(is_unindented)
- def peek(self,n=0):
+ def peek(self, n=0):
if self._l + n < len(self._str):
return self[self._l + n]
else:
@@ -104,16 +105,16 @@ def __init__(self, docstring, config={}):
'References': '',
'Examples': '',
'index': {}
- }
+ }
self._other_keys = []
self._parse()
- def __getitem__(self,key):
+ def __getitem__(self, key):
return self._parsed_data[key]
- def __setitem__(self,key,val):
- if not self._parsed_data.has_key(key):
+ def __setitem__(self, key, val):
+ if key not in self._parsed_data:
self._other_keys.append(key)
self._parsed_data[key] = val
@@ -129,19 +130,21 @@ def _is_at_section(self):
if l1.startswith('.. index::'):
return True
- l2 = self._doc.peek(1).strip() # ---------- or ==========
+ l2 = self._doc.peek(1).strip() # ---------- or ==========
return l2.startswith('-'*len(l1)) or l2.startswith('='*len(l1))
- def _strip(self,doc):
+ def _strip(self, doc):
i = 0
j = 0
- for i,line in enumerate(doc):
- if line.strip(): break
+ for i, line in enumerate(doc):
+ if line.strip():
+ break
- for j,line in enumerate(doc[::-1]):
- if line.strip(): break
+ for j, line in enumerate(doc[::-1]):
+ if line.strip():
+ break
- return doc[i:len(doc)-j]
+ return doc[i:len(doc) - j]
def _read_to_next_section(self):
section = self._doc.read_to_next_empty_line()
@@ -166,7 +169,7 @@ def _read_sections(self):
else:
yield name, self._strip(data[2:])
- def _parse_param_list(self,content):
+ def _parse_param_list(self, content):
r = Reader(content)
params = []
while not r.eof():
@@ -179,13 +182,13 @@ def _parse_param_list(self,content):
desc = r.read_to_next_unindented_line()
desc = dedent_lines(desc)
- params.append((arg_name,arg_type,desc))
+ params.append((arg_name, arg_type, desc))
return params
-
_name_rgx = re.compile(r"^\s*(:(?P<role>\w+):`(?P<name>[a-zA-Z0-9_.-]+)`|"
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
+
def _parse_see_also(self, content):
"""
func_name : Descriptive text
@@ -218,7 +221,8 @@ def push_item(name, rest):
rest = []
for line in content:
- if not line.strip(): continue
+ if not line.strip():
+ continue
m = self._name_rgx.match(line)
if m and line[m.end():].strip().startswith(':'):
@@ -281,7 +285,7 @@ def _parse(self):
self._doc.reset()
self._parse_summary()
- for (section,content) in self._read_sections():
+ for (section, content) in self._read_sections():
if not section.startswith('..'):
section = ' '.join([s.capitalize() for s in section.split(' ')])
if section in ('Parameters', 'Returns', 'Raises', 'Warns',
@@ -307,7 +311,7 @@ def _str_indent(self, doc, indent=4):
def _str_signature(self):
if self['Signature']:
- return [self['Signature'].replace('*','\*')] + ['']
+ return [self['Signature'].replace('*', '\*')] + ['']
else:
return ['']
@@ -327,7 +331,7 @@ def _str_param_list(self, name):
out = []
if self[name]:
out += self._str_header(name)
- for param,param_type,desc in self[name]:
+ for param, param_type, desc in self[name]:
out += ['%s : %s' % (param, param_type)]
out += self._str_indent(desc)
out += ['']
@@ -342,7 +346,8 @@ def _str_section(self, name):
return out
def _str_see_also(self, func_role):
- if not self['See Also']: return []
+ if not self['See Also']:
+ return []
out = []
out += self._str_header("See Also")
last_had_desc = True
@@ -369,7 +374,7 @@ def _str_see_also(self, func_role):
def _str_index(self):
idx = self['index']
out = []
- out += ['.. index:: %s' % idx.get('default','')]
+ out += ['.. index:: %s' % idx.get('default', '')]
for section, references in idx.iteritems():
if section == 'default':
continue
@@ -386,7 +391,7 @@ def __str__(self, func_role=''):
out += self._str_param_list(param_list)
out += self._str_section('Warnings')
out += self._str_see_also(func_role)
- for s in ('Notes','References','Examples'):
+ for s in ('Notes', 'References', 'Examples'):
out += self._str_section(s)
for param_list in ('Attributes', 'Methods'):
out += self._str_param_list(param_list)
@@ -394,7 +399,7 @@ def __str__(self, func_role=''):
return '\n'.join(out)
-def indent(str,indent=4):
+def indent(str, indent=4):
indent_str = ' '*indent
if str is None:
return indent_str
@@ -426,7 +431,7 @@ def __init__(self, func, role='func', doc=None, config={}):
# try to read signature
argspec = inspect.getargspec(func)
argspec = inspect.formatargspec(*argspec)
- argspec = argspec.replace('*','\*')
+ argspec = argspec.replace('*', '\*')
signature = '%s%s' % (func_name, argspec)
except TypeError, e:
signature = '%s()' % func_name
@@ -450,9 +455,9 @@ def __str__(self):
'meth': 'method'}
if self._role:
- if not roles.has_key(self._role):
+ if self._role not in roles:
print "Warning: invalid role %s" % self._role
- out += '.. %s:: %s\n \n\n' % (roles.get(self._role,''),
+ out += '.. %s:: %s\n \n\n' % (roles.get(self._role, ''),
func_name)
out += super(FunctionDoc, self).__str__(func_role=self._role)
@@ -492,7 +497,7 @@ def __init__(self, cls, doc=None, modulename='', func_doc=FunctionDoc,
def methods(self):
if self._cls is None:
return []
- return [name for name,func in inspect_getmembers(self._cls)
+ return [name for name, func in inspect_getmembers(self._cls)
if ((not name.startswith('_')
or name in self.extra_public_methods)
and callable(func))]
@@ -501,11 +506,10 @@ def methods(self):
def properties(self):
if self._cls is None:
return []
- return [name for name,func in inspect_getmembers(self._cls)
+ return [name for name, func in inspect_getmembers(self._cls)
if not name.startswith('_') and func is None]
-
# This function was taken verbatim from Python 2.7 inspect.getmembers() from
# the standard library. The difference from Python < 2.7 is that there is the
# try/except AttributeError clause added, which catches exceptions like this
17 doc/ext/docscrape_sphinx.py
View
@@ -1,4 +1,7 @@
-import re, inspect, textwrap, pydoc
+import re
+import inspect
+import textwrap
+import pydoc
import sphinx
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
@@ -38,11 +41,11 @@ def _str_param_list(self, name):
if self[name]:
out += self._str_field_list(name)
out += ['']
- for param,param_type,desc in self[name]:
+ for param, param_type, desc in self[name]:
out += self._str_indent(['**%s** : %s' % (param.strip(),
param_type)])
out += ['']
- out += self._str_indent(desc,8)
+ out += self._str_indent(desc, 8)
out += ['']
return out
@@ -130,7 +133,7 @@ def _str_index(self):
if len(idx) == 0:
return out
- out += ['.. index:: %s' % idx.get('default','')]
+ out += ['.. index:: %s' % idx.get('default', '')]
for section, references in idx.iteritems():
if section == 'default':
continue
@@ -151,9 +154,9 @@ def _str_references(self):
# Latex collects all references to a separate bibliography,
# so we need to insert links to it
if sphinx.__version__ >= "0.6":
- out += ['.. only:: latex','']
+ out += ['.. only:: latex', '']
else:
- out += ['.. latexonly::','']
+ out += ['.. latexonly::', '']
items = []
for line in self['References']:
m = re.match(r'.. \[([a-z0-9._-]+)\]', line, re.I)
@@ -193,7 +196,7 @@ def __str__(self, indent=0, func_role="obj"):
for s in self._other_keys:
out += self._str_section(s)
out += self._str_member_list('Attributes')
- out = self._str_indent(out,indent)
+ out = self._str_indent(out, indent)
return '\n'.join(out)
class SphinxFunctionDoc(SphinxDocString, FunctionDoc):
16 doc/ext/numpydoc.py
View
@@ -22,7 +22,9 @@
if sphinx.__version__ < '1.0.1':
raise RuntimeError("Sphinx 1.0.1 or newer is required")
-import os, re, pydoc
+import os
+import re
+import pydoc
from docscrape_sphinx import get_doc_object, SphinxDocString
from sphinx.util.compat import Directive
import inspect
@@ -36,14 +38,14 @@ def mangle_docstrings(app, what, name, obj, options, lines,
if what == 'module':
# Strip top title
title_re = re.compile(ur'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
- re.I|re.S)
+ re.I | re.S)
lines[:] = title_re.sub(u'', u"\n".join(lines)).split(u"\n")
else:
doc = get_doc_object(obj, what, u"\n".join(lines), config=cfg)
lines[:] = unicode(doc).split(u"\n")
if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \
- obj.__name__:
+ obj.__name__:
if hasattr(obj, '__module__'):
v = dict(full_name=u"%s.%s" % (obj.__module__, obj.__name__))
else:
@@ -80,11 +82,13 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
# Do not try to inspect classes that don't define `__init__`
if (inspect.isclass(obj) and
(not hasattr(obj, '__init__') or
- 'initializes x; see ' in pydoc.getdoc(obj.__init__))):
+ 'initializes x; see ' in pydoc.getdoc(obj.__init__))):
return '', ''
- if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return
- if not hasattr(obj, '__doc__'): return
+ if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')):
+ return
+ if not hasattr(obj, '__doc__'):
+ return
doc = SphinxDocString(pydoc.getdoc(obj))
if doc['Signature']:
32 doc/src/conf.py
View
@@ -22,7 +22,7 @@
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.addons.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.mathjax',
- 'numpydoc', 'sympylive',]
+ 'numpydoc', 'sympylive', ]
# Use this to use pngmath instead
#extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.pngmath', ]
@@ -143,8 +143,8 @@
# Additional stuff for the LaTeX preamble.
# Tweaked to work with XeTeX.
latex_elements = {
- 'babel': '',
- 'fontenc': r'''
+ 'babel': '',
+ 'fontenc': r'''
\usepackage{amssymb}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
@@ -152,10 +152,10 @@
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}
''',
- 'fontpkg': '',
- 'inputenc': '',
- 'utf8extra': '',
- 'preamble': ''
+ 'fontpkg': '',
+ 'inputenc': '',
+ 'utf8extra': '',
+ 'preamble': ''
}
# SymPy logo on title page
@@ -171,18 +171,16 @@
latex_use_modindex = False
default_role = 'math'
-pngmath_divpng_args = ['-gamma 1.5','-D 110']
+pngmath_divpng_args = ['-gamma 1.5', '-D 110']
# Note, this is ignored by the mathjax extension
# Any \newcommand should be defined in the file
-pngmath_latex_preamble = '\\usepackage{amsmath}\n'+\
- '\\usepackage{bm}\n'+\
- '\\usepackage{amsfonts}\n'+\
- '\\usepackage{amssymb}\n'+\
- '\\setlength{\\parindent}{0pt}\n'
+pngmath_latex_preamble = '\\usepackage{amsmath}\n' \
+ '\\usepackage{bm}\n' \
+ '\\usepackage{amsfonts}\n' \
+ '\\usepackage{amssymb}\n' \
+ '\\setlength{\\parindent}{0pt}\n'
texinfo_documents = [
- (master_doc, 'sympy', 'SymPy Documentation',
- 'SymPy Development Team',
- 'SymPy', 'Computer algebra system (CAS) in Python', 'Programming',
- 1),
+ (master_doc, 'sympy', 'SymPy Documentation', 'SymPy Development Team',
+ 'SymPy', 'Computer algebra system (CAS) in Python', 'Programming', 1),
]
34 doc/src/modules/galgebra/GA/BasicGAtest.py
View
@@ -1,28 +1,28 @@
- a,b,c,d,e = MV.setup('a b c d e')
+ a, b, c, d, e = MV.setup('a b c d e')
MV.set_str_format(1)
- print 'e|(a^b) =',e|(a^b)
- print 'e|(a^b^c) =',e|(a^b^c)
- print 'a*(b^c)-b*(a^c)+c*(a^b) =',a*(b^c)-b*(a^c)+c*(a^b)
- print 'e|(a^b^c^d) =',e|(a^b^c^d)
- print -d*(a^b^c)+c*(a^b^d)-b*(a^c^d)+a*(b^c^d)
+ print 'e|(a^b) =', e | (a ^ b)
+ print 'e|(a^b^c) =', e | (a ^ b ^ c)
+ print 'a*(b^c)-b*(a^c)+c*(a^b) =', a*(b ^ c) - b*(a ^ c) + c*(a ^ b)
+ print 'e|(a^b^c^d) =', e | (a ^ b ^ c ^ d)
+ print -d*(a ^ b ^ c) + c*(a ^ b ^ d) - b*(a ^ c ^ d) + a*(b ^ c ^ d)
- print (a^b)|(c^d)
+ print (a ^ b) | (c ^ d)
-e|(a^b) = {-(b.e)}a
+e | (a ^ b) = {-(b.e)}a
+{(a.e)}b
-e|(a^b^c) = {(c.e)}a^b
-+{-(b.e)}a^c
-+{(a.e)}b^c
+e | (a ^ b ^ c) = {(c.e)}a ^ b
++{-(b.e)}a ^ c
++{(a.e)}b ^ c
-a*(b^c)-b*(a^c)+c*(a^b) = {3}a^b^c
+a*(b ^ c) - b*(a ^ c) + c*(a ^ b) = {3}a ^ b ^ c
-e|(a^b^c^d) = {-(d.e)}a^b^c
-+{(c.e)}a^b^d
-+{-(b.e)}a^c^d
-+{(a.e)}b^c^d
+e | (a ^ b ^ c ^ d) = {-(d.e)}a ^ b ^ c
++{(c.e)}a ^ b ^ d
++{-(b.e)}a ^ c ^ d
++{(a.e)}b ^ c ^ d
-{4}a^b^c^d
+{4}a ^ b ^ c ^ d
{(a.d)*(b.c) - (a.c)*(b.d)}1
22 doc/src/modules/galgebra/GA/Dirac.py
View
@@ -7,20 +7,20 @@
if __name__ == '__main__':
- metric = '1 0 0 0,'+\
- '0 -1 0 0,'+\
- '0 0 -1 0,'+\
+ metric = '1 0 0 0,' \
+ '0 -1 0 0,' \
+ '0 0 -1 0,' \
'0 0 0 -1'
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)
+ 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')
+ m, e = symbols('m e')
Format('1 1 1 1')
- I = MV(ONE,'pseudo')
+ I = MV(ONE, 'pseudo')
nvars = len(vars)
- psi = MV('psi','spinor',fct=True)
- A = MV('A','vector',fct=True)
+ psi = MV('psi', 'spinor', 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
@@ -28,11 +28,11 @@
print A
print r'$\bm{\psi}$ is 8-component real spinor (even multi-vector)'
print psi
- dirac_eq = psi.grad()*I*sig_z-e*A*psi-m*psi*gamma_t
+ dirac_eq = psi.grad()*I*sig_z - e*A*psi - m*psi*gamma_t
dirac_eq.simplify()
- print 'Dirac equation in terms of real geometric algebra/calculus '+\
+ print 'Dirac equation in terms of real geometric algebra/calculus ' \
r'$\lp\nabla \bm{\psi} I \sigma_{z}-eA\bm{\psi} = m\bm{\psi}\gamma_{t}\rp$'
print 'Spin measured with respect to $z$ axis'
Format('mv=3')
- print r'\nabla \bm{\psi} I \sigma_{z}-eA\bm{\psi}-m\bm{\psi}\gamma_{t} = ',dirac_eq,' = 0'
+ print r'\nabla \bm{\psi} I \sigma_{z}-eA\bm{\psi}-m\bm{\psi}\gamma_{t} = ', dirac_eq, ' = 0'
xdvi(filename='Dirac.tex')
40 doc/src/modules/galgebra/GA/Maxwell.py
View
@@ -5,42 +5,42 @@
if __name__ == '__main__':
- metric = '1 0 0 0,'+\
- '0 -1 0 0,'+\
- '0 0 -1 0,'+\
+ metric = '1 0 0 0,' \
+ '0 -1 0 0,' \
+ '0 0 -1 0,' \
'0 0 0 -1'
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)
- LatexPrinter.format(1,1,1,1)
- I = MV(1,'pseudo')
+ gamma_t, gamma_x, gamma_y, gamma_z = MV.setup('gamma_t gamma_x gamma_y gamma_z', metric, True, vars)
+ LatexPrinter.format(1, 1, 1, 1)
+ I = MV(1, 'pseudo')
print '$I$ Pseudo-Scalar'
- print 'I =',I
- B = MV('B','vector',fct=True)
- E = MV('E','vector',fct=True)
- B.set_coef(1,0,0)
- E.set_coef(1,0,0)
+ print 'I =', I
+ B = MV('B', 'vector', fct=True)
+ E = MV('E', 'vector', fct=True)
+ B.set_coef(1, 0, 0)
+ E.set_coef(1, 0, 0)
B *= gamma_t
E *= gamma_t
- J = MV('J','vector',fct=True)
- F = E+I*B
+ J = MV('J', 'vector', fct=True)
+ F = E + I*B
print ' '
print '$B$ Magnetic Field Bi-Vector'
- print 'B = Bvec gamma_0 =',B
+ print 'B = Bvec gamma_0 =', B
print '$F$ Electric Field Bi-Vector'
- print 'E = Evec gamma_0 =',E
+ print 'E = Evec gamma_0 =', E
print '$E+IB$ Electo-Magnetic Field Bi-Vector'
- print 'F = E+IB =',F
+ print 'F = E+IB =', F
print '$J$ Four Current'
- print 'J =',J
+ print 'J =', J
gradF = F.grad()
print 'Geometric Derivative of Electo-Magnetic Field Bi-Vector'
MV_format(3)
- print '\\nabla F =',gradF
+ print '\\nabla F =', gradF
print 'All Maxwell Equations are'
print '\\nabla F = J'
print 'Div $E$ and Curl $H$ Equations'
- print '<\\nabla F>_1 -J =',gradF.project(1)-J,' = 0'
+ print '<\\nabla F>_1 -J =', gradF.project(1) - J, ' = 0'
print 'Curl $E$ and Div $B$ equations'
- print '<\\nabla F>_3 =',gradF.project(3),' = 0'
+ print '<\\nabla F>_3 =', gradF.project(3), ' = 0'
xdvi(filename='Maxwell.tex')
51 doc/src/modules/galgebra/GA/conformalgeometryGAtest.py
View
@@ -2,45 +2,50 @@
metric = '1 0 0 0 0,0 1 0 0 0,0 0 1 0 0,0 0 0 0 2,0 0 0 2 0'
- e0,e1,e2,n,nbar = MV.setup('e0 e1 e2 n nbar',metric,debug=0)
+ e0, e1, e2, n, nbar = MV.setup('e0 e1 e2 n nbar', metric, debug=0)
MV.set_str_format(1)
- e = n+nbar
+ e = n + nbar
#conformal representation of points
- A = F(e0,n,nbar) # point a = (1,0,0) A = F(a)
- B = F(e1,n,nbar) # point b = (0,1,0) B = F(b)
- C = F(-1*e0,n,nbar) # point c = (-1,0,0) C = F(c)
- D = F(e2,n,nbar) # point d = (0,0,1) D = F(d)
- x0,x1,x2 = sympy.symbols('x0 x1 x2')
- X = F(MV([x0,x1,x2],'vector'),n,nbar)
+ A = F(e0, n, nbar) # point a = (1,0,0) A = F(a)
+ B = F(e1, n, nbar) # point b = (0,1,0) B = F(b)
+ C = F(-1*e0, n, nbar) # point c = (-1,0,0) C = F(c)
+ D = F(e2, n, nbar) # point d = (0,0,1) D = F(d)
+ x0, x1, x2 = sympy.symbols('x0 x1 x2')
+ X = F(MV([x0, x1, x2], 'vector'), n, nbar)
print 'a = e0, b = e1, c = -e0, and d = e2'
print 'A = F(a) = 1/2*(a*a*n+2*a-nbar), etc.'
print 'Circle through a, b, and c'
- print 'Circle: A^B^C^X = 0 =',(A^B^C^X)
+ print 'Circle: A^B^C^X = 0 =', (A ^ B ^ C ^ X)
print 'Line through a and b'
- print 'Line : A^B^n^X = 0 =',(A^B^n^X)
+ print 'Line : A^B^n^X = 0 =', (A ^ B ^ n ^ X)
print 'Sphere through a, b, c, and d'
- print 'Sphere: A^B^C^D^X = 0 =',(A^B^C^D^X)
+ print 'Sphere: A^B^C^D^X = 0 =', (A ^ B ^ C ^ D ^ X)
print 'Plane through a, b, and d'
- print 'Plane : A^B^n^D^X = 0 =',(A^B^n^D^X)
+ print 'Plane : A^B^n^D^X = 0 =', (A ^ B ^ n ^ D ^ X)
-Example: Conformal representations of circles, lines, spheres, and planes
+Example:
+ Conformal representations of circles, lines, spheres, and planes
a = e0, b = e1, c = -e0, and d = e2
-A = F(a) = 1/2*(a*a*n+2*a-nbar), etc.
+A = F(a) = 1/2*(a*a*n + 2*a - nbar), etc.
Circle through a, b, and c
-Circle: A^B^C^X = 0 = {-x2}e0^e1^e2^n
-+{x2}e0^e1^e2^nbar
-+{-1/2 + 1/2*x0**2 + 1/2*x1**2 + 1/2*x2**2}e0^e1^n^nbar
+Circle:
+ A ^ B ^ C ^ X = 0 = {-x2}e0 ^ e1 ^ e2 ^ n
++{x2}e0 ^ e1 ^ e2 ^ nbar
++{-1/2 + 1/2*x0**2 + 1/2*x1**2 + 1/2*x2**2}e0 ^ e1 ^ n ^ nbar
Line through a and b
-Line : A^B^n^X = 0 = {-x2}e0^e1^e2^n
-+{-1/2 + x0/2 + x1/2}e0^e1^n^nbar
-+{x2/2}e0^e2^n^nbar
-+{-x2/2}e1^e2^n^nbar
+Line:
+ A ^ B ^ n ^ X = 0 = {-x2}e0 ^ e1 ^ e2 ^ n
++{-1/2 + x0/2 + x1/2}e0 ^ e1 ^ n ^ nbar
++{x2/2}e0 ^ e2 ^ n ^ nbar
++{-x2/2}e1 ^ e2 ^ n ^ nbar
Sphere through a, b, c, and d
-Sphere: A^B^C^D^X = 0 = {1/2 - 1/2*x0**2 - 1/2*x1**2 - 1/2*x2**2}e0^e1^e2^n^nbar
+Sphere:
+ A ^ B ^ C ^ D ^ X = 0 = {1/2 - 1/2*x0**2 - 1/2*x1**2 - 1/2*x2**2}e0 ^ e1 ^ e2 ^ n ^ nbar
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
+Plane:
+ A ^ B ^ n ^ D ^ X = 0 = {1/2 - x0/2 - x1/2 - x2/2}e0 ^ e1 ^ e2 ^ n ^ nbar
30 doc/src/modules/galgebra/GA/coords.py
View
@@ -5,42 +5,44 @@
from sympy.galgebra.latex_ex import *
from sympy import *
-import sympy,numpy,sys
+import sympy
+import numpy
+import sys
if __name__ == '__main__':
- metric = '1 0 0,'+\
- '0 1 0,'+\
+ metric = '1 0 0,' +\
+ '0 1 0,' +\
'0 0 1'
- gamma_x,gamma_y,gamma_z = MV.setup('gamma_x gamma_y gamma_z',metric,True)
+ gamma_x, gamma_y, gamma_z = MV.setup('gamma_x gamma_y gamma_z', metric, True)
Format('1 1 1 1')
- coords = r,theta,phi = symbols('r theta phi')
- x = r*(sympy.cos(theta)*gamma_z+sympy.sin(theta)*\
- (sympy.cos(phi)*gamma_x+sympy.sin(phi)*gamma_y))
+ coords = r, theta, phi = symbols('r theta phi')
+ x = r*(sympy.cos(theta)*gamma_z + sympy.sin(theta)*
+ (sympy.cos(phi)*gamma_x + sympy.sin(phi)*gamma_y))
x.set_name('x')
- MV.rebase(x,coords,'e',False)
+ MV.rebase(x, coords, 'e', False)
#psi = MV.scalar_fct('psi')
- psi = MV('psi','scalar',fct=True)
+ psi = MV('psi', 'scalar', fct=True)
#psi.name = 'psi'
dpsi = psi.grad()
print 'Gradient of Scalar Function $\\psi$'
- print '\\nabla\\psi =',dpsi
+ print '\\nabla\\psi =', dpsi
#A = MV.vector_fct('A')
- A = MV('A','vector',fct=True)
+ 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')
+ I = MV(ONE, 'pseudo')
divA = A.grad_int()
curlA = -I*A.grad_ext()
- print '\\nabla \\cdot A =',divA
+ print '\\nabla \\cdot A =', divA
Format('mv=3')
- print '-I\\lp\\nabla \\W A\\rp =',curlA
+ print '-I\\lp\\nabla \\W A\\rp =', curlA
xdvi(filename='coords.tex')
6 doc/src/modules/galgebra/GA/headerGAtest.py
View
@@ -1,4 +1,6 @@
-import os,sys,sympy
+import os
+import sys
+import sympy
from sympy.galgebra.GA import MV, ZERO, ONE, HALF
from sympy import collect, symbols
@@ -6,7 +8,7 @@ def F(x, n, nbar):
"""
Conformal Mapping Function
"""
- Fx = HALF*((x*x)*n+2*x-nbar)
+ Fx = HALF*((x*x)*n + 2*x - nbar)
return(Fx)
if __name__ == '__main__':
214 doc/src/modules/galgebra/GA/hyperbolicGAtest.py
View
@@ -1,125 +1,125 @@
- print 'Example: non-euclidian distance calculation'
-
- metric = '0 # #,# 0 #,# # 1'
- X,Y,e = MV.setup('X Y e',metric)
- XdotY = sympy.Symbol('(X.Y)')
- Xdote = sympy.Symbol('(X.e)')
- Ydote = sympy.Symbol('(Y.e)')
- MV.set_str_format(1)
- L = X^Y^e
- B = L*e
- Bsq = (B*B)()
- print 'L = X^Y^e is a non-euclidian line'
- print 'B = L*e =',B
- BeBr =B*e*B.rev()
- print 'B*e*B.rev() =',BeBr
- print 'B^2 =',Bsq
- print 'L^2 =',(L*L)()
- s,c,Binv,M,S,C,alpha = symbols('s c Binv M S C alpha')
- Bhat = Binv*B # Normalize translation generator
- R = c+s*Bhat # Rotor R = exp(alpha*Bhat/2)
- print 's = sinh(alpha/2) and c = cosh(alpha/2)'
- print 'R = exp(alpha*B/(2*|B|)) =',R
- Z = R*X*R.rev()
- Z.expand()
- Z.collect([Binv,s,c,XdotY])
- print 'R*X*R.rev() =',Z
- W = Z|Y
- W.expand()
- W.collect([s*Binv])
- print '(R*X*rev(R)).Y =',W
- M = 1/Bsq
- W.subs(Binv**2,M)
- W.simplify()
- Bmag = sympy.sqrt(XdotY**2-2*XdotY*Xdote*Ydote)
- W.collect([Binv*c*s,XdotY])
-
- W.subs(2*XdotY**2-4*XdotY*Xdote*Ydote,2/(Binv**2))
- W.subs(2*c*s,S)
- W.subs(c**2,(C+1)/2)
- W.subs(s**2,(C-1)/2)
- W.simplify()
- W.subs(1/Binv,Bmag)
- W = W().expand()
- print '(R*X*R.rev()).Y =',W
- nl = '\n'
-
- Wd = collect(W,[C,S],exact=True,evaluate=False)
- print 'Wd =',Wd
- Wd_1 = Wd[ONE]
- Wd_C = Wd[C]
- Wd_S = Wd[S]
- print '|B| =',Bmag
- Wd_1 = Wd_1.subs(Bmag,1/Binv)
- Wd_C = Wd_C.subs(Bmag,1/Binv)
- Wd_S = Wd_S.subs(Bmag,1/Binv)
- print 'Wd[ONE] =',Wd_1
- print 'Wd[C] =',Wd_C
- print 'Wd[S] =',Wd_S
-
-
- lhs = Wd_1+Wd_C*C
- rhs = -Wd_S*S
- lhs = lhs**2
- rhs = rhs**2
- W = (lhs-rhs).expand()
- W = (W.subs(1/Binv**2,Bmag**2)).expand()
- print 'W =',W
- W = (W.subs(S**2,C**2-1)).expand()
- print 'W =',W
- W = collect(W,[C,C**2],evaluate=False)
- print 'W =',W
-
- a = W[C**2]
- b = W[C]
- c = W[ONE]
-
- print 'a =',a
- print 'b =',b
- print 'c =',c
-
- D = (b**2-4*a*c).expand()
- print 'Setting to 0 and solving for C gives:'
- print 'Descriminant D = b^2-4*a*c =',D
- C = (-b/(2*a)).expand()
- print 'C = cosh(alpha) = -b/(2*a) =',C
-
-Example: non-euclidian distance calculation
-L = X^Y^e is a non-euclidian line
-B = L*e = X^Y
-+{-(Y.e)}X^e
-+{(X.e)}Y^e
+ print 'Example: non-euclidian distance calculation'
+
+ metric = '0 # #,# 0 #,# # 1'
+ X, Y, e = MV.setup('X Y e', metric)
+ XdotY = sympy.Symbol('(X.Y)')
+ Xdote = sympy.Symbol('(X.e)')
+ Ydote = sympy.Symbol('(Y.e)')
+ MV.set_str_format(1)
+ L = X ^ Y ^ e
+ B = L*e
+ Bsq = (B*B)()
+ print 'L = X^Y^e is a non-euclidian line'
+ print 'B = L*e =', B
+ BeBr = B*e*B.rev()
+ print 'B*e*B.rev() =', BeBr
+ print 'B^2 =', Bsq
+ print 'L^2 =', (L*L)()
+ s, c, Binv, M, S, C, alpha = symbols('s c Binv M S C alpha')
+ Bhat = Binv*B # Normalize translation generator
+ R = c + s*Bhat # Rotor R = exp(alpha*Bhat/2)
+ print 's = sinh(alpha/2) and c = cosh(alpha/2)'
+ print 'R = exp(alpha*B/(2*|B|)) =', R
+ Z = R*X*R.rev()
+ Z.expand()
+ Z.collect([Binv, s, c, XdotY])
+ print 'R*X*R.rev() =', Z
+ W = Z | Y
+ W.expand()
+ W.collect([s*Binv])
+ print '(R*X*rev(R)).Y =', W
+ M = 1/Bsq
+ W.subs(Binv**2, M)
+ W.simplify()
+ Bmag = sympy.sqrt(XdotY**2 - 2*XdotY*Xdote*Ydote)
+ W.collect([Binv*c*s, XdotY])
+
+ W.subs(2*XdotY**2 - 4*XdotY*Xdote*Ydote, 2/(Binv**2))
+ W.subs(2*c*s, S)
+ W.subs(c**2, (C + 1)/2)
+ W.subs(s**2, (C - 1)/2)
+ W.simplify()
+ W.subs(1/Binv, Bmag)
+ W = W().expand()
+ print '(R*X*R.rev()).Y =', W
+ nl = '\n'
+
+ Wd = collect(W, [C, S], exact=True, evaluate=False)
+ print 'Wd =', Wd
+ Wd_1 = Wd[ONE]
+ Wd_C = Wd[C]
+ Wd_S = Wd[S]
+ print '|B| =', Bmag
+ Wd_1 = Wd_1.subs(Bmag, 1/Binv)
+ Wd_C = Wd_C.subs(Bmag, 1/Binv)
+ Wd_S = Wd_S.subs(Bmag, 1/Binv)
+ print 'Wd[ONE] =', Wd_1
+ print 'Wd[C] =', Wd_C
+ print 'Wd[S] =', Wd_S
+
+ lhs = Wd_1 + Wd_C*C
+ rhs = -Wd_S*S
+ lhs = lhs**2
+ rhs = rhs**2
+ W = (lhs - rhs).expand()
+ W = (W.subs(1/Binv**2, Bmag**2)).expand()
+ print 'W =', W
+ W = (W.subs(S**2, C**2 - 1)).expand()
+ print 'W =', W
+ W = collect(W, [C, C**2], evaluate=False)
+ print 'W =', W
+
+ a = W[C**2]
+ b = W[C]
+ c = W[ONE]
+
+ print 'a =', a
+ print 'b =', b
+ print 'c =', c
+
+ D = (b**2 - 4*a*c).expand()
+ print 'Setting to 0 and solving for C gives:'
+ print 'Descriminant D = b^2-4*a*c =', D
+ C = (-b/(2*a)).expand()
+ print 'C = cosh(alpha) = -b/(2*a) =', C
+
+Example:
+ non - euclidian distance calculation
+L = X ^ Y ^ e is a non - euclidian line
+B = L*e = X ^ Y
++{-(Y.e)}X ^ e
++{(X.e)}Y ^ e
B*e*B.rev() = {2*(X.Y)*(X.e)*(Y.e) - (X.Y)**2}e
-B^2 = -2*(X.Y)*(X.e)*(Y.e) + (X.Y)**2
-L^2 = -2*(X.Y)*(X.e)*(Y.e) + (X.Y)**2
+B ^ 2 = -2*(X.Y)*(X.e)*(Y.e) + (X.Y)**2
+L ^ 2 = -2*(X.Y)*(X.e)*(Y.e) + (X.Y)**2
s = sinh(alpha/2) and c = cosh(alpha/2)
-R = exp(alpha*B/(2*|B|)) = {c}1
-+{Binv*s}X^Y
-+{-(Y.e)*Binv*s}X^<