[Yt-svn] yt-commit r1304 - in trunk/yt: . fido lagos reason

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Tue May 12 23:22:19 PDT 2009


Author: mturk
Date: Tue May 12 23:22:18 2009
New Revision: 1304
URL: http://yt.spacepope.org/changeset/1304

Log:
Lots of little changes and removals

 * Raise a KeyError explicitly if a parameter is not found in get_parameter_line
 * Remove enki import
 * Remove overloads of | operators, which are cool but not really appropriate
 * Got rid of some old config variables
 * Added SIGUSR2 handler to send RuntimeError; useful for use inside pdb
 * Ditch some old options for fortran handling
 * Got rid of the multiple means of handling logging; there is now only the unified log file



Modified:
   trunk/yt/__init__.py
   trunk/yt/config.py
   trunk/yt/fido/__init__.py
   trunk/yt/funcs.py
   trunk/yt/lagos/__init__.py
   trunk/yt/logger.py
   trunk/yt/mods.py
   trunk/yt/reason/App.py
   trunk/yt/reason/Toolbars.py
   trunk/yt/reason/__init__.py

Modified: trunk/yt/__init__.py
==============================================================================
--- trunk/yt/__init__.py	(original)
+++ trunk/yt/__init__.py	Tue May 12 23:22:18 2009
@@ -78,7 +78,3 @@
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
-
-#from yt.logger import *
-#from yt.config import *
-#from yt.funcs import *

Modified: trunk/yt/config.py
==============================================================================
--- trunk/yt/config.py	(original)
+++ trunk/yt/config.py	Tue May 12 23:22:18 2009
@@ -47,18 +47,14 @@
         'ReconstructHierarchy': 'True',
         'serialize' : 'True',
         'onlydeserialize' : 'False',
-        'usefortran' : 'False',
-        'useswig' : 'False',
         'loadfieldplugins':'False',
         'pluginfilename':'yt_plugins.py',
-        'nounitslength':'1.0',
         },
     "yt":{
         'LogFile': 'False',
         'LogFileName': 'yt.log',
         'suppressStreamLogging': 'False',
         'LogLevel': '20',
-        'unifiedlogfile': '1',
         'timefunctions':'False',
         'inGui':'False',
         '__parallel':'False',
@@ -71,7 +67,6 @@
     "raven":{
         'ImagePath':".",
         'ImageSkel': '%(bn)s_%(width)010i_%(unit)s',
-        'backend': 'MPL',
         'colormap': 'jet',
         }
     }

Modified: trunk/yt/fido/__init__.py
==============================================================================
--- trunk/yt/fido/__init__.py	(original)
+++ trunk/yt/fido/__init__.py	Tue May 12 23:22:18 2009
@@ -42,9 +42,12 @@
 def get_parameter_line(filename, parameter):
     f = open(filename)
     lines = filter(lambda a: a.startswith(parameter), f)
-    if len(lines) > 1:
+    if len(lines) == 0:
+        raise KeyError(parameter)
+    elif len(lines) > 1:
         raise KeyError, "More than one line matches that parameter!"
-    else: return lines[0]
+    else:
+        return lines[0]
 
 def get_parent_dir(filename):
     return os.path.normpath( \

Modified: trunk/yt/funcs.py
==============================================================================
--- trunk/yt/funcs.py	(original)
+++ trunk/yt/funcs.py	Tue May 12 23:22:18 2009
@@ -27,6 +27,7 @@
 import warnings
 import progressbar as pb
 from math import floor, ceil
+from yt.logger import ytLogger as mylog
 
 def signal_print_traceback(signo, frame):
     print traceback.print_stack(frame)
@@ -36,7 +37,9 @@
 
 try:
     signal.signal(signal.SIGUSR1, signal_print_traceback)
+    mylog.debug("SIGUSR1 registered for traceback printing")
     signal.signal(signal.SIGUSR2, signal_problem)
+    mylog.debug("SIGUSR2 registered for RuntimeError")
 except ValueError:  # Not in main thread
     pass
 
@@ -96,7 +99,6 @@
         mylog.debug('%s took %0.3f s', func.func_name, (t2-t1))
         return res
     from yt.config import ytcfg
-    from yt.logger import lagosLogger as mylog
     if ytcfg.getboolean("yt","timefunctions") == True:
         return wrapper
     else:
@@ -118,10 +120,10 @@
      %(filename)s:%(lineno)s
 """
 
-def insert_ipython():
+def insert_ipython(num_up=1):
     from IPython.Shell import IPShellEmbed
     stack = inspect.stack()
-    frame = inspect.stack()[1]
+    frame = inspect.stack()[num_up]
     loc = frame[0].f_locals.copy()
     glo = frame[0].f_globals
     dd = dict(fname = frame[3], filename = frame[1],
@@ -165,7 +167,6 @@
 
 def get_pbar(title, maxval):
     from yt.config import ytcfg
-    from yt.logger import lagosLogger as mylog
     if ytcfg.getboolean("yt","inGui"):
         if maxval > ytcfg.getint("reason","minpbar"): # Arbitrary number
             return GUIProgressBar(title, maxval)

Modified: trunk/yt/lagos/__init__.py
==============================================================================
--- trunk/yt/lagos/__init__.py	(original)
+++ trunk/yt/lagos/__init__.py	Tue May 12 23:22:18 2009
@@ -55,18 +55,6 @@
 from Cosmology import *
 from EnzoCosmology import *
 
-if ytcfg.getboolean("lagos","useswig"):
-    try:
-        from yt.enki import EnzoInterface
-    except ImportError:
-        pass
-
-if ytcfg.getboolean("lagos","usefortran"):
-    try:
-        import EnzoFortranRoutines
-    except ImportError:
-        mylog.warning("Told to import fortan, but unable!")
-
 # Now we import all the subfiles
 
 from HelperFunctions import *

Modified: trunk/yt/logger.py
==============================================================================
--- trunk/yt/logger.py	(original)
+++ trunk/yt/logger.py	Tue May 12 23:22:18 2009
@@ -59,56 +59,14 @@
 file_handlers = []
 
 if ytcfg.getboolean("yt","logfile") and os.access(".", os.W_OK):
-    if ytcfg.getboolean("yt","unifiedlogfile"):
-        log_file_name = ytcfg.get("yt","LogFileName")
-        ytFileHandler = handlers.RotatingFileHandler(log_file_name,
-                                                 maxBytes=mb, backupCount=bc)
-        k = logging.Formatter(fstring)
-        ytFileHandler.setFormatter(k)
-        ytLogger.addHandler(ytFileHandler)
-        loggers.append(ytLogger)
-        file_handlers.append(ytFileHandler)
-    else:
-        # If we *don't* want a unified file handler (which is the default now!)
-        fidoFileHandler = handlers.RotatingFileHandler("fido.log",
-                                                   maxBytes=mb, backupCount=bc)
-        fidoFileHandler.setFormatter(f)
-        fidoLogger.addHandler(fidoFileHandler)
-
-        ravenFileHandler = handlers.RotatingFileHandler("raven.log",
-                                                    maxBytes=mb, backupCount=bc)
-        ravenFileHandler.setFormatter(f)
-        ravenLogger.addHandler(ravenFileHandler)
-        loggers.append(ravenLogger)
-        file_handlers.append(ravenFileHandler)
-
-        lagosFileHandler = handlers.RotatingFileHandler("lagos.log",
-                                                    maxBytes=mb, backupCount=bc)
-        lagosFileHandler.setFormatter(f)
-        lagosLogger.addHandler(lagosFileHandler)
-        loggers.append(lagosLogger)
-        file_handlers.append(lagosFileHandler)
-
-        enkiFileHandler = handlers.RotatingFileHandler("enki.log",
-                                                   maxBytes=mb, backupCount=bc)
-        enkiFileHandler.setFormatter(f)
-        enkiLogger.addHandler(enkiFileHandler)
-        loggers.append(enkiLogger)
-        file_handlers.append(enkiFileHandler)
-
-        deliveratorFileHandler = handlers.RotatingFileHandler("deliverator.log",
-                                                maxBytes=mb, backupCount=bc)
-        deliveratorFileHandler.setFormatter(f)
-        deliveratorLogger.addHandler(deliveratorFileHandler)
-        loggers.append(deliveratorLogger)
-        file_handlers.append(deliveratorFileHandler)
-
-        reasonFileHandler = handlers.RotatingFileHandler("reason.log",
-                                                    maxBytes=mb, backupCount=bc)
-        reasonFileHandler.setFormatter(f)
-        reasonLogger.addHandler(reasonFileHandler)
-        loggers.append(reasonLogger)
-        file_handlers.append(reasonFileHandler)
+    log_file_name = ytcfg.get("yt","LogFileName")
+    ytFileHandler = handlers.RotatingFileHandler(log_file_name,
+                                             maxBytes=mb, backupCount=bc)
+    k = logging.Formatter(fstring)
+    ytFileHandler.setFormatter(k)
+    ytLogger.addHandler(ytFileHandler)
+    loggers.append(ytLogger)
+    file_handlers.append(ytFileHandler)
 
 def disable_stream_logging():
     # We just remove the root logger's handlers

Modified: trunk/yt/mods.py
==============================================================================
--- trunk/yt/mods.py	(original)
+++ trunk/yt/mods.py	Tue May 12 23:22:18 2009
@@ -79,92 +79,3 @@
 def get_pc():
     return PlotCollection(EnzoStaticOutput(sys.argv[-1]))
 
-# Now the | operator overloading
-# (which is totally a stunt)
-
-class _StaticOutputIfier(object):
-    def __init__(self):
-        pass
-    def __ror__(self, other):
-        return EnzoStaticOutput(other)
-static = _StaticOutputIfier()
-
-class __PlotVM(object):
-    def __init__(self, axis = 0, field = "Density", name = None,
-                width = None, **kwargs):
-        self.axis = axis
-        self.field = field
-        self.name = name
-        self.width = width
-        self.kwargs = kwargs
-
-    def __ror__(self, pf):
-        if isinstance(pf, types.StringTypes): pf = EnzoStaticOutput(pf)
-        pc = PlotCollection(pf)
-        self._add_plot(pc)
-        if self.name is None: self.name = str(pf)
-        if self.width is not None:
-            pc.set_width(*self.width)
-        return pc.save(self.name)
-
-    def __call__(self, *args, **kwargs):
-        return type(self)(*args, **kwargs)
-
-class _PlotSlice(__PlotVM):
-    def _add_plot(self, pc):
-        pc.add_slice(self.field, self.axis, **self.kwargs)
-x_slicer = _PlotSlice(axis=0)
-y_slicer = _PlotSlice(axis=1)
-z_slicer = _PlotSlice(axis=2)
-
-class _PlotProj(__PlotVM):
-    def _add_plot(self, pc):
-        pc.add_projection(self.field, self.axis, **self.kwargs)
-x_projector = _PlotProj(axis=0)
-y_projector = _PlotProj(axis=1)
-z_projector = _PlotProj(axis=2)
-
-class __MultiPlotter(object):
-    def __init__(self, field = "Density", name = None, width = None, **kwargs):
-        self.field = field
-        self.name = name
-        self.width = width
-        self.kwargs = kwargs
-
-    def __ror__(self, pf):
-        if isinstance(pf, types.StringTypes): pf = EnzoStaticOutput(pf)
-        pc = PlotCollection(pf)
-        self._add_plot(pc)
-        if self.name is None: self.name = str(pf)
-        if self.width is not None:
-            pc.set_width(*self.width)
-        return pc.save(self.name)
-
-    def __call__(self, *args, **kwargs):
-        return type(self)(*args, **kwargs)
-
-class _MultiPlotSlice(__PlotVM):
-    def _add_plot(self, pc):
-        for ax in range(3): pc.add_slice(self.field, ax, **self.kwargs)
-slicer = _MultiPlotSlice()
-
-class _MultiPlotProj(__PlotVM):
-    def _add_plot(self, pc):
-        for ax in range(3): pc.add_projection(self.field, ax, **self.kwargs)
-projector = _MultiPlotProj()
-
-# Now some recipes
-#
-# NOTE HIGH LEVEL OF MAGIC.
-# This is not for advanced users.
-
-def _get_current_pf():
-    # We continue until we have 'pf' in the locals space
-    import inspect
-    for s in inspect.stack()[1:]:
-        if 'pf' in s[0].f_locals:
-            __pf = s[0].f_locals['pf']
-            if isinstance(__pf, types.StringTypes):
-                __pf = EnzoStaticOutput(__pf)
-            mylog.info("Obtained parameter file %s", __pf)
-            return __pf

Modified: trunk/yt/reason/App.py
==============================================================================
--- trunk/yt/reason/App.py	(original)
+++ trunk/yt/reason/App.py	Tue May 12 23:22:18 2009
@@ -79,7 +79,6 @@
         self.data_objects = []
         self.locals = {'lagos':lagos,
                        'raven':raven,
-                       'enki':enki,
                        'raven':raven,
                        'outputs':self.outputs,
                        'windows':self.windows,

Modified: trunk/yt/reason/Toolbars.py
==============================================================================
--- trunk/yt/reason/Toolbars.py	(original)
+++ trunk/yt/reason/Toolbars.py	Tue May 12 23:22:18 2009
@@ -26,7 +26,6 @@
 
 import yt.lagos as lagos
 import yt.raven as raven
-import yt.enki as enki
 import yt.fido as fido
 import yt
 

Modified: trunk/yt/reason/__init__.py
==============================================================================
--- trunk/yt/reason/__init__.py	(original)
+++ trunk/yt/reason/__init__.py	Tue May 12 23:22:18 2009
@@ -30,7 +30,6 @@
 
 import yt.lagos as lagos
 import yt.raven as raven
-import yt.enki as enki
 import yt.fido as fido
 
 from yt.arraytypes import *



More information about the yt-svn mailing list