[yt-svn] commit/yt: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Dec 3 15:10:52 PST 2013
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/f1e6e156e083/
Changeset: f1e6e156e083
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-03 16:44:59
Summary: Adding a setup_function argument to the TimeSeries object.
Affected #: 1 file
diff -r 831c3d55fb61b11b8686e6c642769ef6306e8d70 -r f1e6e156e083bdbbe558ffd480ca4a55f494d156 yt/data_objects/time_series.py
--- a/yt/data_objects/time_series.py
+++ b/yt/data_objects/time_series.py
@@ -90,9 +90,13 @@
... SlicePlot(pf, "x", "Density").save()
"""
- def __init__(self, outputs, parallel = True ,**kwargs):
+ def __init__(self, outputs, parallel = True, setup_function = None,
+ **kwargs):
self.tasks = AnalysisTaskProxy(self)
self.params = TimeSeriesParametersContainer(self)
+ if setup_function is None:
+ setup_function = lambda a: None
+ self._setup_function = setup_function
self._pre_outputs = outputs[:]
for type_name in data_object_registry:
setattr(self, type_name, functools.partial(
@@ -104,7 +108,9 @@
# We can make this fancier, but this works
for o in self._pre_outputs:
if isinstance(o, types.StringTypes):
- yield load(o,**self.kwargs)
+ pf = load(o, **self.kwargs)
+ self._setup_function(pf)
+ yield pf
else:
yield o
@@ -116,7 +122,8 @@
return TimeSeriesData(self._pre_outputs[key], self.parallel)
o = self._pre_outputs[key]
if isinstance(o, types.StringTypes):
- o = load(o,**self.kwargs)
+ o = load(o, **self.kwargs)
+ self._setup_function(o)
return o
def __len__(self):
@@ -215,7 +222,8 @@
return [v for k, v in sorted(return_values.items())]
@classmethod
- def from_filenames(cls, filenames, parallel = True, **kwargs):
+ def from_filenames(cls, filenames, parallel = True, setup_function = None,
+ **kwargs):
r"""Create a time series from either a filename pattern or a list of
filenames.
@@ -239,6 +247,8 @@
this is set to either True or an integer, it will be iterated with
1 or that integer number of processors assigned to each parameter
file provided to the loop.
+ setup_function : callable, accepts a pf
+ This function will be called whenever a parameter file is loaded.
Examples
--------
@@ -262,7 +272,8 @@
else:
filenames = glob.glob(filenames)
filenames.sort()
- obj = cls(filenames[:], parallel = parallel, **kwargs)
+ obj = cls(filenames[:], parallel = parallel,
+ setup_function = setup_function, **kwargs)
return obj
@classmethod
https://bitbucket.org/yt_analysis/yt/commits/f9efa112e4c5/
Changeset: f9efa112e4c5
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-03 19:50:34
Summary: Adding some docstring examples for setup_function
Affected #: 1 file
diff -r f1e6e156e083bdbbe558ffd480ca4a55f494d156 -r f9efa112e4c5d397bd924f9600eb5abe7c497ed5 yt/data_objects/time_series.py
--- a/yt/data_objects/time_series.py
+++ b/yt/data_objects/time_series.py
@@ -170,7 +170,12 @@
This demonstrates how one might store results:
- >>> ts = TimeSeriesData.from_filenames("DD*/DD*.hierarchy")
+ >>> def print_time(pf):
+ ... print pf.current_time
+ ...
+ >>> ts = TimeSeriesData.from_filenames("DD*/DD*.hierarchy",
+ ... setup_function = print_time )
+ ...
>>> my_storage = {}
>>> for sto, pf in ts.piter(storage=my_storage):
... v, c = pf.h.find_max("Density")
@@ -253,8 +258,13 @@
Examples
--------
+ >>> def print_time(pf):
+ ... print pf.current_time
+ ...
>>> ts = TimeSeriesData.from_filenames(
- "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0")
+ ... "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0",
+ ... setup_function = print_time)
+ ...
>>> for pf in ts:
... SlicePlot(pf, "x", "Density").save()
https://bitbucket.org/yt_analysis/yt/commits/832e577e09aa/
Changeset: 832e577e09aa
Branch: yt-3.0
User: brittonsmith
Date: 2013-12-04 00:10:45
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #663)
Adding a setup_function argument to the TimeSeries object.
Affected #: 1 file
diff -r 500acd8e6551234e9eb8c0421e60527bc7c2753d -r 832e577e09aad2d5b07202994acdad47e76f2617 yt/data_objects/time_series.py
--- a/yt/data_objects/time_series.py
+++ b/yt/data_objects/time_series.py
@@ -90,9 +90,13 @@
... SlicePlot(pf, "x", "Density").save()
"""
- def __init__(self, outputs, parallel = True ,**kwargs):
+ def __init__(self, outputs, parallel = True, setup_function = None,
+ **kwargs):
self.tasks = AnalysisTaskProxy(self)
self.params = TimeSeriesParametersContainer(self)
+ if setup_function is None:
+ setup_function = lambda a: None
+ self._setup_function = setup_function
self._pre_outputs = outputs[:]
for type_name in data_object_registry:
setattr(self, type_name, functools.partial(
@@ -104,7 +108,9 @@
# We can make this fancier, but this works
for o in self._pre_outputs:
if isinstance(o, types.StringTypes):
- yield load(o,**self.kwargs)
+ pf = load(o, **self.kwargs)
+ self._setup_function(pf)
+ yield pf
else:
yield o
@@ -116,7 +122,8 @@
return TimeSeriesData(self._pre_outputs[key], self.parallel)
o = self._pre_outputs[key]
if isinstance(o, types.StringTypes):
- o = load(o,**self.kwargs)
+ o = load(o, **self.kwargs)
+ self._setup_function(o)
return o
def __len__(self):
@@ -163,7 +170,12 @@
This demonstrates how one might store results:
- >>> ts = TimeSeriesData.from_filenames("DD*/DD*.hierarchy")
+ >>> def print_time(pf):
+ ... print pf.current_time
+ ...
+ >>> ts = TimeSeriesData.from_filenames("DD*/DD*.hierarchy",
+ ... setup_function = print_time )
+ ...
>>> my_storage = {}
>>> for sto, pf in ts.piter(storage=my_storage):
... v, c = pf.h.find_max("Density")
@@ -215,7 +227,8 @@
return [v for k, v in sorted(return_values.items())]
@classmethod
- def from_filenames(cls, filenames, parallel = True, **kwargs):
+ def from_filenames(cls, filenames, parallel = True, setup_function = None,
+ **kwargs):
r"""Create a time series from either a filename pattern or a list of
filenames.
@@ -239,12 +252,19 @@
this is set to either True or an integer, it will be iterated with
1 or that integer number of processors assigned to each parameter
file provided to the loop.
+ setup_function : callable, accepts a pf
+ This function will be called whenever a parameter file is loaded.
Examples
--------
+ >>> def print_time(pf):
+ ... print pf.current_time
+ ...
>>> ts = TimeSeriesData.from_filenames(
- "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0")
+ ... "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0",
+ ... setup_function = print_time)
+ ...
>>> for pf in ts:
... SlicePlot(pf, "x", "Density").save()
@@ -262,7 +282,8 @@
else:
filenames = glob.glob(filenames)
filenames.sort()
- obj = cls(filenames[:], parallel = parallel, **kwargs)
+ obj = cls(filenames[:], parallel = parallel,
+ setup_function = setup_function, **kwargs)
return obj
@classmethod
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