[Yt-svn] commit/yt: jsoishi: added skip parameter to all_pfs

Bitbucket commits-noreply at bitbucket.org
Thu Aug 18 17:04:05 PDT 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/aeb58bc7726e/
changeset:   aeb58bc7726e
branch:      yt
user:        jsoishi
date:        2011-08-19 02:03:58
summary:     added skip parameter to all_pfs
affected #:  1 file (130 bytes)

--- a/yt/convenience.py	Wed Aug 17 14:24:17 2011 -0400
+++ b/yt/convenience.py	Thu Aug 18 17:03:58 2011 -0700
@@ -35,12 +35,14 @@
     output_type_registry, \
     EnzoRunDatabase
 
-def all_pfs(basedir='.',max_depth=1, name_spec="*.hierarchy", **kwargs):
+def all_pfs(basedir='.', skip=None, max_depth=1, name_spec="*.hierarchy", **kwargs):
     """
-    This function searchs a directory and its sub-directories, up to a depth of
-    *max_depth*, for parameter files.  It looks for the *name_spec* and then
-    instantiates an EnzoStaticOutput from each.  All subsequent *kwargs* are
-    passed on to the EnzoStaticOutput constructor.
+    This function searchs a directory and its sub-directories, up to a
+    depth of *max_depth*, for parameter files.  It looks for the
+    *name_spec* and then instantiates an EnzoStaticOutput from
+    each. You can skip every *skip* parameter files, if *skip* is not
+    None; otherwise it will return all files.  All subsequent *kwargs*
+    are passed on to the EnzoStaticOutput constructor.
     """
     list_of_names = []
     basedir = os.path.expanduser(basedir)
@@ -48,7 +50,7 @@
         bb = list('*' * i) + [name_spec]
         list_of_names += glob.glob(os.path.join(basedir,*bb))
     list_of_names.sort(key=lambda b: os.path.basename(b))
-    for fn in list_of_names:
+    for fn in list_of_names[::skip]:
         yield load(fn[:-10], **kwargs)
 
 def max_spheres(width, unit, **kwargs):

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