[yt-svn] commit/yt: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Wed Nov 30 08:26:59 PST 2011
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/893b363bf7e0/
changeset: 893b363bf7e0
branch: yt
user: MatthewTurk
date: 2011-11-30 15:55:35
summary: Changing plugin filename variable to _fn to avoid potential confusion
affected #: 1 file
diff -r a519b8754ba86d786f6ed525584101183e86c6cc -r 893b363bf7e0557aeb2377b1a33ddf02a15922aa yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -133,9 +133,9 @@
my_plugin_name = ytcfg.get("yt","pluginfilename")
# We assume that it is with respect to the $HOME/.yt directory
if os.path.isfile(my_plugin_name):
- fn = my_plugin_name
+ _fn = my_plugin_name
else:
- fn = os.path.expanduser("~/.yt/%s" % my_plugin_name)
- if os.path.isfile(fn):
- mylog.info("Loading plugins from %s", fn)
- execfile(fn)
+ _fn = os.path.expanduser("~/.yt/%s" % my_plugin_name)
+ if os.path.isfile(_fn):
+ mylog.info("Loading plugins from %s", _fn)
+ execfile(_fn)
https://bitbucket.org/yt_analysis/yt/changeset/5c9ac6b8e610/
changeset: 5c9ac6b8e610
branch: yt
user: MatthewTurk
date: 2011-11-30 17:25:37
summary: Refactoring _generate_field and _generate_field_in_grids to be part of AMRData,
not the subclasses. Adding a bunch of decorators for restore_grid_state
anywhere that get_data_from_grid is called.
affected #: 2 files
diff -r 893b363bf7e0557aeb2377b1a33ddf02a15922aa -r 5c9ac6b8e6101bfe75c0d6829cf80026306b270f yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -322,8 +322,28 @@
pass
del self.field_data[key]
- def _generate_field_in_grids(self, fieldName):
- pass
+ def _generate_field(self, field):
+ if self.pf.field_info.has_key(field):
+ # First we check the validator
+ try:
+ self.pf.field_info[field].check_available(self)
+ except NeedsGridType, ngt_exception:
+ # We leave this to be implementation-specific
+ self._generate_field_in_grids(field, ngt_exception.ghost_zones)
+ return False
+ else:
+ self[field] = self.pf.field_info[field](self)
+ return True
+ else: # Can't find the field, try as it might
+ raise KeyError(field)
+
+ def _generate_field_in_grids(self, field, num_ghost_zones=0):
+ for grid in self._grids:
+ grid[field] = self.__touch_grid_field(grid, field)
+
+ @restore_grid_state
+ def __touch_grid_field(self, grid, field):
+ return grid[field]
_key_fields = None
def write_out(self, filename, fields=None, format="%0.16e"):
@@ -454,25 +474,6 @@
self._sortkey = None
self._sorted = {}
- def _generate_field_in_grids(self, field, num_ghost_zones=0):
- for grid in self._grids:
- temp = grid[field]
-
- def _generate_field(self, field):
- if self.pf.field_info.has_key(field):
- # First we check the validator
- try:
- self.pf.field_info[field].check_available(self)
- except NeedsGridType, ngt_exception:
- # We leave this to be implementation-specific
- self._generate_field_in_grids(field, ngt_exception.ghost_zones)
- return False
- else:
- self[field] = self.pf.field_info[field](self)
- return True
- else: # Can't find the field, try as it might
- raise KeyError(field)
-
def get_data(self, fields=None, in_grids=False):
if self._grids == None:
self._get_list_of_grids()
@@ -563,6 +564,7 @@
& (self.py < self.pf.hierarchy.grid_right_edge[:,self.py_ax]))
self._grids = self.hierarchy.grids[y]
+ @restore_grid_state
def _get_data_from_grid(self, grid, field):
# We are orthogonal, so we can feel free to make assumptions
# for the sake of speed.
@@ -657,6 +659,7 @@
t = t.reshape((t.shape[0],1))
return self.start_point + t*self.vec
+ @restore_grid_state
def _get_data_from_grid(self, grid, field):
mask = na.logical_and(self._get_cut_mask(grid),
grid.child_mask)
@@ -739,6 +742,7 @@
p = na.all((min_streampoint <= RE) & (max_streampoint > LE), axis=1)
self._grids = self.hierarchy.grids[p]
+ @restore_grid_state
def _get_data_from_grid(self, grid, field):
mask = na.logical_and(self._get_cut_mask(grid),
grid.child_mask)
@@ -828,25 +832,6 @@
for field in temp_data.keys():
self[field] = temp_data[field]
- def _generate_field(self, field):
- if self.pf.field_info.has_key(field):
- # First we check the validator
- try:
- self.pf.field_info[field].check_available(self)
- except NeedsGridType, ngt_exception:
- # We leave this to be implementation-specific
- self._generate_field_in_grids(field, ngt_exception.ghost_zones)
- return False
- else:
- self[field] = self.pf.field_info[field](self)
- return True
- else: # Can't find the field, try as it might
- raise KeyError(field)
-
- def _generate_field_in_grids(self, field, num_ghost_zones=0):
- for grid in self._grids:
- temp = grid[field]
-
def to_frb(self, width, resolution, center = None):
if center is None:
center = self.get_field_parameter("center")
@@ -1623,9 +1608,9 @@
# _project_level, then it would be more memory conservative
if self.preload_style == 'all':
dependencies = self.get_dependencies(fields, ghost_zones = False)
- print "Preloading %s grids and getting %s" % (
- len(self.source._get_grid_objs()),
- dependencies)
+ mylog.debug("Preloading %s grids and getting %s",
+ len(self.source._get_grid_objs()),
+ dependencies)
self.comm.preload([g for g in self._get_grid_objs()],
dependencies, self.hierarchy.io)
# By changing the remove-from-tree method to accumulate, we can avoid
@@ -2256,6 +2241,7 @@
dls[level].append(float(just_one(grid['d%s' % axis_names[self.axis]])))
return dls
+ @restore_grid_state
def _get_data_from_grid(self, grid, fields, dls):
g_fields = [grid[field].astype("float64") for field in fields]
c_fields = [self[field] for field in fields]
@@ -2393,29 +2379,6 @@
grid[field] = new_field
i += np
- def _generate_field(self, field):
- if self.pf.field_info.has_key(field):
- # First we check the validator
- try:
- self.pf.field_info[field].check_available(self)
- except NeedsGridType, ngt_exception:
- # We leave this to be implementation-specific
- self._generate_field_in_grids(field, ngt_exception.ghost_zones)
- return False
- else:
- self[field] = self.pf.field_info[field](self)
- return True
- else: # Can't find the field, try as it might
- raise KeyError(field)
-
- def _generate_field_in_grids(self, field, num_ghost_zones=0):
- for grid in self._grids:
- self.__touch_grid_field(grid, field)
-
- @restore_grid_state
- def __touch_grid_field(self, grid, field):
- grid[field]
-
def _is_fully_enclosed(self, grid):
return na.all(self._get_cut_mask)
@@ -3504,6 +3467,7 @@
output_field, output_left)
self.field_data[field] = output_field
+ @restore_grid_state
def _get_data_from_grid(self, grid, fields):
fields = ensure_list(fields)
g_fields = [grid[field].astype("float64") for field in fields]
diff -r 893b363bf7e0557aeb2377b1a33ddf02a15922aa -r 5c9ac6b8e6101bfe75c0d6829cf80026306b270f yt/visualization/plot_collection.py
--- a/yt/visualization/plot_collection.py
+++ b/yt/visualization/plot_collection.py
@@ -400,7 +400,7 @@
if coord == None:
coord = center[axis]
if obj is None:
- if field_parameters == None: field_parameters = {}
+ if field_parameters is None: field_parameters = {}
obj = self.pf.hierarchy.slice(axis, coord, field,
center=center, **field_parameters)
p = self._add_plot(SlicePlot(
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list