[yt-svn] commit/yt: chummels: Merged in MatthewTurk/yt (pull request #2062)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Mar 24 08:06:24 PDT 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/f12067d78ef4/
Changeset:   f12067d78ef4
Branch:      yt
User:        chummels
Date:        2016-03-24 15:06:15+00:00
Summary:     Merged in MatthewTurk/yt (pull request #2062)

Adding ability to specify DatasetSeries is not a mixed data type.
Affected #:  1 file

diff -r 66d8895f15b34d51b001a3618ff9c89f5bc765a9 -r f12067d78ef445599aa567bc5e38a6406bef9f06 yt/data_objects/time_series.py
--- a/yt/data_objects/time_series.py
+++ b/yt/data_objects/time_series.py
@@ -123,6 +123,10 @@
         file provided to the loop.
     setup_function : callable, accepts a ds
         This function will be called whenever a dataset is loaded.
+    mixed_dataset_types : True or False, default False
+        Set to True if the DatasetSeries will load different dataset types, set
+        to False if loading dataset of a single type as this will result in a
+        considerable speed up from not having to figure out the dataset type.
 
     Examples
     --------
@@ -154,8 +158,9 @@
         return ret
 
     def __init__(self, outputs, parallel = True, setup_function = None,
-                 **kwargs):
+                 mixed_dataset_types = False, **kwargs):
         # This is needed to properly set _pre_outputs for Simulation subclasses.
+        self._mixed_dataset_types = mixed_dataset_types
         if iterable(outputs) and not isinstance(outputs, string_types):
             self._pre_outputs = outputs[:]
         self.tasks = AnalysisTaskProxy(self)
@@ -173,7 +178,7 @@
         # We can make this fancier, but this works
         for o in self._pre_outputs:
             if isinstance(o, string_types):
-                ds = load(o, **self.kwargs)
+                ds = self._load(o, **self.kwargs)
                 self._setup_function(ds)
                 yield ds
             else:
@@ -187,7 +192,7 @@
             return DatasetSeries(self._pre_outputs[key], self.parallel)
         o = self._pre_outputs[key]
         if isinstance(o, string_types):
-            o = load(o, **self.kwargs)
+            o = self._load(o, **self.kwargs)
             self._setup_function(o)
         return o
 
@@ -278,7 +283,7 @@
                 sto, output = output
 
             if isinstance(output, string_types):
-                ds = load(output, **self.kwargs)
+                ds = self._load(output, **self.kwargs)
                 self._setup_function(ds)
             else:
                 ds = output
@@ -384,6 +389,16 @@
         obj = cls(filenames, parallel = parallel)
         return obj
 
+    _dataset_cls = None
+    def _load(self, output_fn, **kwargs):
+        if self._dataset_cls is not None:
+            return self._dataset_cls(output_fn, **kwargs)
+        elif self._mixed_dataset_types:
+            return load(output_fn, **kwargs)
+        ds = load(output_fn, **kwargs)
+        self._dataset_cls = ds.__class__
+        return ds
+
 class TimeSeriesQuantitiesContainer(object):
     def __init__(self, data_object, quantities):
         self.data_object = data_object

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-svn-spacepope.org/attachments/20160324/b2f10c5c/attachment.htm>


More information about the yt-svn mailing list