[Yt-svn] yt: Adding a new "amods" object to yt.mods that will load-on-dem...
hg at spacepope.org
hg at spacepope.org
Sat Sep 25 18:10:05 PDT 2010
hg Repository: yt
details: yt/rev/2026a9e7f7ca
changeset: 3415:2026a9e7f7ca
user: Matthew Turk <matthewturk at gmail.com>
date:
Sat Sep 25 18:09:56 2010 -0700
description:
Adding a new "amods" object to yt.mods that will load-on-demand analysis
modules.
diffstat:
yt/analysis_modules/list_modules.py | 18 ++++++++++++++++++
yt/data_objects/field_info_container.py | 1 +
yt/mods.py | 2 +-
3 files changed, 20 insertions(+), 1 deletions(-)
diffs (55 lines):
diff -r 164ec43b20d7 -r 2026a9e7f7ca yt/analysis_modules/list_modules.py
--- a/yt/analysis_modules/list_modules.py Sat Sep 25 13:52:58 2010 -0700
+++ b/yt/analysis_modules/list_modules.py Sat Sep 25 18:09:56 2010 -0700
@@ -24,6 +24,7 @@
"""
import os
+import sys
def get_available_modules():
modpath = os.path.abspath(os.path.dirname(__file__))
@@ -32,3 +33,20 @@
if os.path.isdir(d) and os.path.isfile(os.path.join(d, "api.py")):
available_modules.append(os.path.basename(d))
return available_modules
+
+class AnalysisModuleLoader(object):
+
+ @property
+ def available_modules(self):
+ return get_available_modules()
+
+ def __getattr__(self, attr):
+ try:
+ name = "yt.analysis_modules.%s.api" % (attr)
+ nm = __import__(name, level=-1)
+ setattr(self, attr, sys.modules[name])
+ except ImportError:
+ raise AttributeError(attr)
+ return getattr(self, attr)
+
+amods = AnalysisModuleLoader()
diff -r 164ec43b20d7 -r 2026a9e7f7ca yt/data_objects/field_info_container.py
--- a/yt/data_objects/field_info_container.py Sat Sep 25 13:52:58 2010 -0700
+++ b/yt/data_objects/field_info_container.py Sat Sep 25 18:09:56 2010 -0700
@@ -142,6 +142,7 @@
Level = 1
NumberOfParticles = 1
_read_exception = None
+ _id_offset = 0
def __init__(self, nd = 16, pf = None):
self.nd = nd
self.ActiveDimensions = [nd,nd,nd]
diff -r 164ec43b20d7 -r 2026a9e7f7ca yt/mods.py
--- a/yt/mods.py Sat Sep 25 13:52:58 2010 -0700
+++ b/yt/mods.py Sat Sep 25 18:09:56 2010 -0700
@@ -65,7 +65,7 @@
ChomboStaticOutput, ChomboFieldInfo, add_chombo_field
from yt.analysis_modules.list_modules import \
- get_available_modules
+ get_available_modules, amods
available_analysis_modules = get_available_modules()
# Import our analysis modules
More information about the yt-svn
mailing list