Commit f7a3c762954f85eef9dce718892a7858cffd35b4
- Diff rendering mode:
- inline
- side by side
convention.py
(34 / 0)
|   | |||
| 1 | import sys | ||
| 2 | sys.path += ["lib","/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages"] | ||
| 1 | 3 | ||
| 4 | caller = sys._getframe(1).f_globals["__name__"] | ||
| 5 | exec "import %s as target" % caller | ||
| 6 | |||
| 7 | target.timeit = __import__("timeit") | ||
| 8 | |||
| 9 | modules = ( | ||
| 10 | "sys", | ||
| 11 | "os", | ||
| 12 | "matplotlib", | ||
| 13 | "mpmath", | ||
| 14 | "numpy", | ||
| 15 | "scipy", | ||
| 16 | "timeit" | ||
| 17 | ) | ||
| 18 | |||
| 19 | for module_name in modules: | ||
| 20 | target.__dict__[module_name] = __import__(module_name) | ||
| 21 | |||
| 22 | target.matplotlib.use("Agg") | ||
| 23 | target.mpmath.mp.dps = 100 | ||
| 24 | |||
| 25 | target.__dict__["pylab"] = __import__("pylab") | ||
| 26 | target.__dict__["pprint"] = __import__("pprint").pprint | ||
| 27 | |||
| 28 | |||
| 29 | # below is obsolete | ||
| 30 | # {{{ | ||
| 31 | |||
| 2 | 32 | def import_convention(scope): | |
| 3 | 33 | code =\ | |
| 4 | 34 | """ | |
| 5 | 35 | import sys, os, matplotlib, mpmath, numpy | |
| 6 | 36 | sys.path += ["lib","/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages"] | |
| 37 | mpmath.mp.dps = 100 | ||
| 7 | 38 | matplotlib.use("Agg") | |
| 8 | 39 | import pylab | |
| 9 | 40 | import scipy | |
| 10 | 41 | from pprint import pprint | |
| 42 | import fdtd | ||
| 11 | 43 | """ | |
| 12 | 44 | exec code in scope | |
| 13 | 45 | pass | |
| 46 | |||
| 47 | # }}} |

