[yt-svn] commit/yt: 6 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Oct 27 13:02:39 PDT 2016


6 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/f2a75d23c38a/
Changeset:   f2a75d23c38a
Branch:      yt
User:        xarthisius
Date:        2016-10-19 18:26:34+00:00
Summary:     Do not store answers if required dataset is not present
Affected #:  2 files

diff -r 34a95afc68047ab60ddf5a20816dfb80291cd99b -r f2a75d23c38a8754bdc5ce0a61c3aef7f401c99c yt/config.py
--- a/yt/config.py
+++ b/yt/config.py
@@ -48,6 +48,7 @@
     reconstruct_index = 'False',
     test_storage_dir = '/does/not/exist',
     test_data_dir = '/does/not/exist',
+    requires_ds_strict = 'False',
     enzo_db = '',
     hub_url = 'https://girder.hub.yt/api/v1',
     hub_api_key = '',

diff -r 34a95afc68047ab60ddf5a20816dfb80291cd99b -r f2a75d23c38a8754bdc5ce0a61c3aef7f401c99c yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -229,7 +229,9 @@
 
 class AnswerTestLocalStorage(AnswerTestStorage):
     def dump(self, result_storage):
-        if self.answer_name is None: return
+        if self.answer_name is None or \
+                result_storage.get('tainted', False):
+            return
         # Store data using shelve
         ds = shelve.open(self.answer_name, protocol=-1)
         for ds_name in result_storage:
@@ -259,34 +261,44 @@
     os.chdir(oldcwd)
 
 def can_run_ds(ds_fn, file_check = False):
+    result_storage = AnswerTestingTest.result_storage
     if isinstance(ds_fn, Dataset):
-        return AnswerTestingTest.result_storage is not None
+        return result_storage is not None
     path = ytcfg.get("yt", "test_data_dir")
     if not os.path.isdir(path):
         return False
     if file_check:
         return os.path.isfile(os.path.join(path, ds_fn)) and \
-            AnswerTestingTest.result_storage is not None
+            result_storage is not None
     try:
         load(ds_fn)
     except YTOutputNotIdentified:
+        if ytcfg.getboolean("yt", "requires_ds_strict"):
+            if result_storage is not None:
+                result_storage['tainted'] = True
+            raise
         return False
-    return AnswerTestingTest.result_storage is not None
+    return result_storage is not None
 
 def can_run_sim(sim_fn, sim_type, file_check = False):
+    result_storage = AnswerTestingTest.result_storage
     if isinstance(sim_fn, SimulationTimeSeries):
-        return AnswerTestingTest.result_storage is not None
+        return result_storage is not None
     path = ytcfg.get("yt", "test_data_dir")
     if not os.path.isdir(path):
         return False
     if file_check:
         return os.path.isfile(os.path.join(path, sim_fn)) and \
-            AnswerTestingTest.result_storage is not None
+            result_storage is not None
     try:
         simulation(sim_fn, sim_type)
     except YTOutputNotIdentified:
+        if ytcfg.getboolean("yt", "requires_ds_strict"):
+            if result_storage is not None:
+                result_storage['tainted'] = True
+            raise
         return False
-    return AnswerTestingTest.result_storage is not None
+    return result_storage is not None
 
 def data_dir_load(ds_fn, cls = None, args = None, kwargs = None):
     args = args or ()


https://bitbucket.org/yt_analysis/yt/commits/8e6818850f7a/
Changeset:   8e6818850f7a
Branch:      yt
User:        xarthisius
Date:        2016-10-25 18:13:19+00:00
Summary:     Store software stack info in the image metadata
Affected #:  4 files

diff -r f2a75d23c38a8754bdc5ce0a61c3aef7f401c99c -r 8e6818850f7aa70a7124808361677eb52ef675a9 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -584,6 +584,10 @@
     version_info['matplotlib'] = matplotlib.__version__
     return version_info
 
+def get_version_stack_str():
+    return 'yt:{}|np:{}|mpl:{}'.format(
+        get_yt_version(), numpy.version.version, matplotlib.__version__)
+
 def get_script_contents():
     top_frame = inspect.stack()[-1]
     finfo = inspect.getframeinfo(top_frame[0])

diff -r f2a75d23c38a8754bdc5ce0a61c3aef7f401c99c -r 8e6818850f7aa70a7124808361677eb52ef675a9 yt/utilities/png_writer.py
--- a/yt/utilities/png_writer.py
+++ b/yt/utilities/png_writer.py
@@ -12,7 +12,9 @@
 
 import matplotlib
 import matplotlib._png as _png
-from yt.extern.six import PY2
+from yt.extern.six import PY2, b
+import numpy
+from yt.funcs import get_yt_version, get_version_stack_str
 
 if PY2:
     from cStringIO import StringIO
@@ -23,12 +25,16 @@
 MPL_VERSION = LooseVersion(matplotlib.__version__)
 MPL_API_2_VERSION = LooseVersion("1.5.0")
 
+STACK_VERSION = 'yt:{}|numpy:{}|mpl:{}'.format(
+    get_yt_version(), numpy.version.version, matplotlib.__version__)
+
 if MPL_VERSION < MPL_API_2_VERSION:
     def call_png_write_png(buffer, width, height, filename, dpi):
         _png.write_png(buffer, width, height, filename, dpi)
 else:
     def call_png_write_png(buffer, width, height, filename, dpi):
-        _png.write_png(buffer, filename, dpi)
+        meta = {b('software'): b(get_version_stack_str())}
+        _png.write_png(buffer, filename, dpi=dpi, metadata=meta)
 
 def write_png(buffer, filename, dpi=100):
     width = buffer.shape[1]

diff -r f2a75d23c38a8754bdc5ce0a61c3aef7f401c99c -r 8e6818850f7aa70a7124808361677eb52ef675a9 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -21,7 +21,9 @@
     iterable, \
     get_brewer_cmap, \
     matplotlib_style_context, \
-    get_interactivity
+    get_interactivity, \
+    get_version_stack_str
+from yt.extern import six
 import numpy as np
 
 backend_dict = {'GTK': ['backend_gtk', 'FigureCanvasGTK',
@@ -137,10 +139,14 @@
 
         if suffix == ".png":
             canvas = FigureCanvasAgg(self.figure)
+            mpl_kwargs['metadata'] = \
+                {six.b('software'): six.b(get_version_stack_str())}
         elif suffix == ".pdf":
             canvas = FigureCanvasPdf(self.figure)
+            mpl_kwargs['metadata'] = {'Creator': get_version_stack_str()}
         elif suffix in (".eps", ".ps"):
             canvas = FigureCanvasPS(self.figure)
+            mpl_kwargs['metadata'] = {'Creator': get_version_stack_str()}
         else:
             mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
             canvas = self.canvas

diff -r f2a75d23c38a8754bdc5ce0a61c3aef7f401c99c -r 8e6818850f7aa70a7124808361677eb52ef675a9 yt/visualization/image_writer.py
--- a/yt/visualization/image_writer.py
+++ b/yt/visualization/image_writer.py
@@ -20,7 +20,8 @@
 from yt.funcs import \
     mylog, \
     get_image_suffix, \
-    get_brewer_cmap
+    get_brewer_cmap, \
+    get_version_stack_str
 from yt.units.yt_array import YTQuantity
 from yt.utilities.exceptions import YTNotInsideNotebook
 from .color_maps import mcm
@@ -28,6 +29,7 @@
 import yt.utilities.lib.image_utilities as au
 import yt.utilities.png_writer as pw
 from yt.extern.six.moves import builtins
+import yt.extern.six as six
 
 
 def scale_image(image, mi=None, ma=None):
@@ -415,17 +417,21 @@
         suffix = '.png'
         filename = "%s%s" % (filename, suffix)
     mylog.info("Saving plot %s", filename)
+    metadata = None
     if suffix == ".png":
         canvas = FigureCanvasAgg(fig)
+        metadata = {six.b('software'): six.b(get_version_stack_str())}
     elif suffix == ".pdf":
         canvas = FigureCanvasPdf(fig)
+        metadata = {'Creator': get_version_stack_str()}
     elif suffix in (".eps", ".ps"):
         canvas = FigureCanvasPS(fig)
+        metadata = {'Creator': get_version_stack_str()}
     else:
         mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
         canvas = FigureCanvasAgg(fig)
 
-    canvas.print_figure(filename, dpi=dpi)
+    canvas.print_figure(filename, dpi=dpi, metadata=metadata)
     return filename
 
 def display_in_notebook(image, max_val=None):


https://bitbucket.org/yt_analysis/yt/commits/18f7094b4071/
Changeset:   18f7094b4071
Branch:      yt
User:        xarthisius
Date:        2016-10-27 16:25:43+00:00
Summary:     Backed out changeset 8e6818850f7a
Affected #:  4 files

diff -r 8e6818850f7aa70a7124808361677eb52ef675a9 -r 18f7094b40710730fa1be37a7cf1155cd598b1c5 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -584,10 +584,6 @@
     version_info['matplotlib'] = matplotlib.__version__
     return version_info
 
-def get_version_stack_str():
-    return 'yt:{}|np:{}|mpl:{}'.format(
-        get_yt_version(), numpy.version.version, matplotlib.__version__)
-
 def get_script_contents():
     top_frame = inspect.stack()[-1]
     finfo = inspect.getframeinfo(top_frame[0])

diff -r 8e6818850f7aa70a7124808361677eb52ef675a9 -r 18f7094b40710730fa1be37a7cf1155cd598b1c5 yt/utilities/png_writer.py
--- a/yt/utilities/png_writer.py
+++ b/yt/utilities/png_writer.py
@@ -12,9 +12,7 @@
 
 import matplotlib
 import matplotlib._png as _png
-from yt.extern.six import PY2, b
-import numpy
-from yt.funcs import get_yt_version, get_version_stack_str
+from yt.extern.six import PY2
 
 if PY2:
     from cStringIO import StringIO
@@ -25,16 +23,12 @@
 MPL_VERSION = LooseVersion(matplotlib.__version__)
 MPL_API_2_VERSION = LooseVersion("1.5.0")
 
-STACK_VERSION = 'yt:{}|numpy:{}|mpl:{}'.format(
-    get_yt_version(), numpy.version.version, matplotlib.__version__)
-
 if MPL_VERSION < MPL_API_2_VERSION:
     def call_png_write_png(buffer, width, height, filename, dpi):
         _png.write_png(buffer, width, height, filename, dpi)
 else:
     def call_png_write_png(buffer, width, height, filename, dpi):
-        meta = {b('software'): b(get_version_stack_str())}
-        _png.write_png(buffer, filename, dpi=dpi, metadata=meta)
+        _png.write_png(buffer, filename, dpi)
 
 def write_png(buffer, filename, dpi=100):
     width = buffer.shape[1]

diff -r 8e6818850f7aa70a7124808361677eb52ef675a9 -r 18f7094b40710730fa1be37a7cf1155cd598b1c5 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -21,9 +21,7 @@
     iterable, \
     get_brewer_cmap, \
     matplotlib_style_context, \
-    get_interactivity, \
-    get_version_stack_str
-from yt.extern import six
+    get_interactivity
 import numpy as np
 
 backend_dict = {'GTK': ['backend_gtk', 'FigureCanvasGTK',
@@ -139,14 +137,10 @@
 
         if suffix == ".png":
             canvas = FigureCanvasAgg(self.figure)
-            mpl_kwargs['metadata'] = \
-                {six.b('software'): six.b(get_version_stack_str())}
         elif suffix == ".pdf":
             canvas = FigureCanvasPdf(self.figure)
-            mpl_kwargs['metadata'] = {'Creator': get_version_stack_str()}
         elif suffix in (".eps", ".ps"):
             canvas = FigureCanvasPS(self.figure)
-            mpl_kwargs['metadata'] = {'Creator': get_version_stack_str()}
         else:
             mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
             canvas = self.canvas

diff -r 8e6818850f7aa70a7124808361677eb52ef675a9 -r 18f7094b40710730fa1be37a7cf1155cd598b1c5 yt/visualization/image_writer.py
--- a/yt/visualization/image_writer.py
+++ b/yt/visualization/image_writer.py
@@ -20,8 +20,7 @@
 from yt.funcs import \
     mylog, \
     get_image_suffix, \
-    get_brewer_cmap, \
-    get_version_stack_str
+    get_brewer_cmap
 from yt.units.yt_array import YTQuantity
 from yt.utilities.exceptions import YTNotInsideNotebook
 from .color_maps import mcm
@@ -29,7 +28,6 @@
 import yt.utilities.lib.image_utilities as au
 import yt.utilities.png_writer as pw
 from yt.extern.six.moves import builtins
-import yt.extern.six as six
 
 
 def scale_image(image, mi=None, ma=None):
@@ -417,21 +415,17 @@
         suffix = '.png'
         filename = "%s%s" % (filename, suffix)
     mylog.info("Saving plot %s", filename)
-    metadata = None
     if suffix == ".png":
         canvas = FigureCanvasAgg(fig)
-        metadata = {six.b('software'): six.b(get_version_stack_str())}
     elif suffix == ".pdf":
         canvas = FigureCanvasPdf(fig)
-        metadata = {'Creator': get_version_stack_str()}
     elif suffix in (".eps", ".ps"):
         canvas = FigureCanvasPS(fig)
-        metadata = {'Creator': get_version_stack_str()}
     else:
         mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
         canvas = FigureCanvasAgg(fig)
 
-    canvas.print_figure(filename, dpi=dpi, metadata=metadata)
+    canvas.print_figure(filename, dpi=dpi)
     return filename
 
 def display_in_notebook(image, max_val=None):


https://bitbucket.org/yt_analysis/yt/commits/53965f42e717/
Changeset:   53965f42e717
Branch:      yt
User:        xarthisius
Date:        2016-10-27 16:35:14+00:00
Summary:     Add documentation for 'requires_ds_strict'
Affected #:  1 file

diff -r 18f7094b40710730fa1be37a7cf1155cd598b1c5 -r 53965f42e71784d58d3896674fb2df533746bb53 doc/source/reference/configuration.rst
--- a/doc/source/reference/configuration.rst
+++ b/doc/source/reference/configuration.rst
@@ -95,6 +95,10 @@
   IPython notebook created by ``yt notebook``.  Note that this should be an
   sha512 hash, not a plaintext password.  Starting ``yt notebook`` with no
   setting will provide instructions for setting this.
+* ``requires_ds_strict`` (default: ``'True'``): If true, answer tests wrapped
+  with :func:`~yt.utilities.answer_testing.framework.requires_ds` will raise
+  :class:`~yt.utilities.exceptions.YTOutputNotIdentified` rather than consuming
+  it if required dataset is not present.
 * ``serialize`` (default: ``'False'``): If true, perform automatic
   :ref:`object serialization <object-serialization>`
 * ``sketchfab_api_key`` (default: empty): API key for https://sketchfab.com/ for


https://bitbucket.org/yt_analysis/yt/commits/425917175850/
Changeset:   425917175850
Branch:      yt
User:        xarthisius
Date:        2016-10-27 16:40:45+00:00
Summary:     Add a comment about the purpose of 'tainted' attribute
Affected #:  1 file

diff -r 53965f42e71784d58d3896674fb2df533746bb53 -r 4259171758504abbaa334a88b6c2b4e92c5e63dc yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -229,8 +229,12 @@
 
 class AnswerTestLocalStorage(AnswerTestStorage):
     def dump(self, result_storage):
-        if self.answer_name is None or \
-                result_storage.get('tainted', False):
+        # The 'tainted' attribute is automatically set to 'True'
+        # if the dataset required for an answer test is missing
+        # (see can_run_ds() and can_run_sim()).
+        # This logic check prevents creating a shelve with empty answers.
+        storage_is_tainted = result_storage.get('tainted', False)
+        if self.answer_name is None or storage_is_tainted:
             return
         # Store data using shelve
         ds = shelve.open(self.answer_name, protocol=-1)


https://bitbucket.org/yt_analysis/yt/commits/aff20fbf4037/
Changeset:   aff20fbf4037
Branch:      yt
User:        ngoldbaum
Date:        2016-10-27 20:02:11+00:00
Summary:     Merged in xarthisius/yt (pull request #2422)

Do not store answers if required dataset is not present
Affected #:  7 files

diff -r d15775018c266934317e4021fad305b4d37e08c5 -r aff20fbf4037f400504edd7d33c88aff92858dbb doc/source/reference/configuration.rst
--- a/doc/source/reference/configuration.rst
+++ b/doc/source/reference/configuration.rst
@@ -95,6 +95,10 @@
   IPython notebook created by ``yt notebook``.  Note that this should be an
   sha512 hash, not a plaintext password.  Starting ``yt notebook`` with no
   setting will provide instructions for setting this.
+* ``requires_ds_strict`` (default: ``'True'``): If true, answer tests wrapped
+  with :func:`~yt.utilities.answer_testing.framework.requires_ds` will raise
+  :class:`~yt.utilities.exceptions.YTOutputNotIdentified` rather than consuming
+  it if required dataset is not present.
 * ``serialize`` (default: ``'False'``): If true, perform automatic
   :ref:`object serialization <object-serialization>`
 * ``sketchfab_api_key`` (default: empty): API key for https://sketchfab.com/ for

diff -r d15775018c266934317e4021fad305b4d37e08c5 -r aff20fbf4037f400504edd7d33c88aff92858dbb yt/config.py
--- a/yt/config.py
+++ b/yt/config.py
@@ -48,6 +48,7 @@
     reconstruct_index = 'False',
     test_storage_dir = '/does/not/exist',
     test_data_dir = '/does/not/exist',
+    requires_ds_strict = 'False',
     enzo_db = '',
     hub_url = 'https://girder.hub.yt/api/v1',
     hub_api_key = '',

diff -r d15775018c266934317e4021fad305b4d37e08c5 -r aff20fbf4037f400504edd7d33c88aff92858dbb yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -229,7 +229,13 @@
 
 class AnswerTestLocalStorage(AnswerTestStorage):
     def dump(self, result_storage):
-        if self.answer_name is None: return
+        # The 'tainted' attribute is automatically set to 'True'
+        # if the dataset required for an answer test is missing
+        # (see can_run_ds() and can_run_sim()).
+        # This logic check prevents creating a shelve with empty answers.
+        storage_is_tainted = result_storage.get('tainted', False)
+        if self.answer_name is None or storage_is_tainted:
+            return
         # Store data using shelve
         ds = shelve.open(self.answer_name, protocol=-1)
         for ds_name in result_storage:
@@ -259,34 +265,44 @@
     os.chdir(oldcwd)
 
 def can_run_ds(ds_fn, file_check = False):
+    result_storage = AnswerTestingTest.result_storage
     if isinstance(ds_fn, Dataset):
-        return AnswerTestingTest.result_storage is not None
+        return result_storage is not None
     path = ytcfg.get("yt", "test_data_dir")
     if not os.path.isdir(path):
         return False
     if file_check:
         return os.path.isfile(os.path.join(path, ds_fn)) and \
-            AnswerTestingTest.result_storage is not None
+            result_storage is not None
     try:
         load(ds_fn)
     except YTOutputNotIdentified:
+        if ytcfg.getboolean("yt", "requires_ds_strict"):
+            if result_storage is not None:
+                result_storage['tainted'] = True
+            raise
         return False
-    return AnswerTestingTest.result_storage is not None
+    return result_storage is not None
 
 def can_run_sim(sim_fn, sim_type, file_check = False):
+    result_storage = AnswerTestingTest.result_storage
     if isinstance(sim_fn, SimulationTimeSeries):
-        return AnswerTestingTest.result_storage is not None
+        return result_storage is not None
     path = ytcfg.get("yt", "test_data_dir")
     if not os.path.isdir(path):
         return False
     if file_check:
         return os.path.isfile(os.path.join(path, sim_fn)) and \
-            AnswerTestingTest.result_storage is not None
+            result_storage is not None
     try:
         simulation(sim_fn, sim_type)
     except YTOutputNotIdentified:
+        if ytcfg.getboolean("yt", "requires_ds_strict"):
+            if result_storage is not None:
+                result_storage['tainted'] = True
+            raise
         return False
-    return AnswerTestingTest.result_storage is not None
+    return result_storage is not None
 
 def data_dir_load(ds_fn, cls = None, args = None, kwargs = None):
     args = args or ()

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