[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Aug 6 07:14:30 PDT 2015
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/a10db48baf88/
Changeset: a10db48baf88
Branch: yt
User: ngoldbaum
Date: 2015-07-29 19:21:03+00:00
Summary: Avoid traceback in find_lowest_subclass if there are no valid candidates
Affected #: 1 file
diff -r 60bd0bc6b0a9d81f1a6a741c5c709725cbc536db -r a10db48baf881f75750c8610cbd9b8a564104564 yt/utilities/hierarchy_inspection.py
--- a/yt/utilities/hierarchy_inspection.py
+++ b/yt/utilities/hierarchy_inspection.py
@@ -32,6 +32,9 @@
counters = [Counter(mro) for mro in mros]
+ if len(counters) == 0:
+ return counters
+
count = reduce(lambda x, y: x + y, counters)
return [x for x in count.keys() if count[x] == 1]
https://bitbucket.org/yt_analysis/yt/commits/7628624cead6/
Changeset: 7628624cead6
Branch: yt
User: ngoldbaum
Date: 2015-07-29 19:37:19+00:00
Summary: Fix ugly struct unpacking tracebacks when loading an empty file.
Affected #: 2 files
diff -r a10db48baf881f75750c8610cbd9b8a564104564 -r 7628624cead6b86836572db9a7561ee9a50bc392 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -264,7 +264,11 @@
# or the byte swapped equivalents (65536 and 134217728).
# The int32 following the header (first 4+256 bytes) must equal this
# number.
- (rhead,) = struct.unpack('<I',f.read(4))
+ try:
+ (rhead,) = struct.unpack('<I',f.read(4))
+ except struct.error:
+ f.close()
+ return False, 1
# Use value to check endianess
if rhead == 256:
endianswap = '<'
diff -r a10db48baf881f75750c8610cbd9b8a564104564 -r 7628624cead6b86836572db9a7561ee9a50bc392 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -255,7 +255,7 @@
f.seek(0, os.SEEK_SET)
#Read in the header
t, n, ndim, ng, nd, ns = struct.unpack("<diiiii", f.read(28))
- except IOError:
+ except (IOError, struct.error):
return False, 1
endianswap = "<"
#Check Endianness
https://bitbucket.org/yt_analysis/yt/commits/301b863c540d/
Changeset: 301b863c540d
Branch: yt
User: ngoldbaum
Date: 2015-07-29 20:15:18+00:00
Summary: Adding tests for laoding invalid files
Affected #: 1 file
diff -r 7628624cead6b86836572db9a7561ee9a50bc392 -r 301b863c540d4325a96d034780779b3880d9950d yt/frontends/stream/tests/test_outputs.py
--- /dev/null
+++ b/yt/frontends/stream/tests/test_outputs.py
@@ -0,0 +1,45 @@
+"""
+Tests for loading in-memory datasets
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2013, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+import os
+import shutil
+import tempfile
+import unittest
+
+from yt.testing import assert_raises
+from yt.utilities.answer_testing.framework import data_dir_load
+from yt.utilities.exceptions import YTOutputNotIdentified
+
+class TestEmptyLoad(unittest.TestCase):
+
+ def setUp(self):
+ self.tmpdir = tempfile.mkdtemp()
+ self.curdir = os.getcwd()
+ os.chdir(self.tmpdir)
+
+ # create 0 byte file
+ open("empty_file", "a")
+
+ # create empty directory
+ os.makedirs("empty_directory")
+
+ def teardown(self):
+ os.chdir(self.curdir)
+ shutil.rmtree(self.tmpdir)
+
+ def test_load_empty_file(self):
+ assert_raises(YTOutputNotIdentified, data_dir_load, "not_a_file")
+ assert_raises(YTOutputNotIdentified, data_dir_load, "empty_file")
+ assert_raises(YTOutputNotIdentified, data_dir_load, "empty_directory")
https://bitbucket.org/yt_analysis/yt/commits/026e13a30052/
Changeset: 026e13a30052
Branch: yt
User: ngoldbaum
Date: 2015-08-05 18:24:33+00:00
Summary: Override the correct tearDown function in stream empty output tests
Affected #: 1 file
diff -r 301b863c540d4325a96d034780779b3880d9950d -r 026e13a30052618b748c6c7f5ac79cacb89e5302 yt/frontends/stream/tests/test_outputs.py
--- a/yt/frontends/stream/tests/test_outputs.py
+++ b/yt/frontends/stream/tests/test_outputs.py
@@ -35,7 +35,7 @@
# create empty directory
os.makedirs("empty_directory")
- def teardown(self):
+ def tearDown(self):
os.chdir(self.curdir)
shutil.rmtree(self.tmpdir)
https://bitbucket.org/yt_analysis/yt/commits/5157b9fc6114/
Changeset: 5157b9fc6114
Branch: yt
User: xarthisius
Date: 2015-08-06 14:14:19+00:00
Summary: Merged in ngoldbaum/yt (pull request #1662)
[BUGFIX] Avoid hard-to-decipher tracebacks when loading empty files or directories
Affected #: 4 files
diff -r fffa77d2fdc205b54fb87befaa50ade850f826d6 -r 5157b9fc61144f54817ec418fdfba9e484c842a7 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -264,7 +264,11 @@
# or the byte swapped equivalents (65536 and 134217728).
# The int32 following the header (first 4+256 bytes) must equal this
# number.
- (rhead,) = struct.unpack('<I',f.read(4))
+ try:
+ (rhead,) = struct.unpack('<I',f.read(4))
+ except struct.error:
+ f.close()
+ return False, 1
# Use value to check endianess
if rhead == 256:
endianswap = '<'
diff -r fffa77d2fdc205b54fb87befaa50ade850f826d6 -r 5157b9fc61144f54817ec418fdfba9e484c842a7 yt/frontends/stream/tests/test_outputs.py
--- /dev/null
+++ b/yt/frontends/stream/tests/test_outputs.py
@@ -0,0 +1,45 @@
+"""
+Tests for loading in-memory datasets
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2013, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+import os
+import shutil
+import tempfile
+import unittest
+
+from yt.testing import assert_raises
+from yt.utilities.answer_testing.framework import data_dir_load
+from yt.utilities.exceptions import YTOutputNotIdentified
+
+class TestEmptyLoad(unittest.TestCase):
+
+ def setUp(self):
+ self.tmpdir = tempfile.mkdtemp()
+ self.curdir = os.getcwd()
+ os.chdir(self.tmpdir)
+
+ # create 0 byte file
+ open("empty_file", "a")
+
+ # create empty directory
+ os.makedirs("empty_directory")
+
+ def tearDown(self):
+ os.chdir(self.curdir)
+ shutil.rmtree(self.tmpdir)
+
+ def test_load_empty_file(self):
+ assert_raises(YTOutputNotIdentified, data_dir_load, "not_a_file")
+ assert_raises(YTOutputNotIdentified, data_dir_load, "empty_file")
+ assert_raises(YTOutputNotIdentified, data_dir_load, "empty_directory")
diff -r fffa77d2fdc205b54fb87befaa50ade850f826d6 -r 5157b9fc61144f54817ec418fdfba9e484c842a7 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -255,7 +255,7 @@
f.seek(0, os.SEEK_SET)
#Read in the header
t, n, ndim, ng, nd, ns = struct.unpack("<diiiii", f.read(28))
- except IOError:
+ except (IOError, struct.error):
return False, 1
endianswap = "<"
#Check Endianness
diff -r fffa77d2fdc205b54fb87befaa50ade850f826d6 -r 5157b9fc61144f54817ec418fdfba9e484c842a7 yt/utilities/hierarchy_inspection.py
--- a/yt/utilities/hierarchy_inspection.py
+++ b/yt/utilities/hierarchy_inspection.py
@@ -32,6 +32,9 @@
counters = [Counter(mro) for mro in mros]
+ if len(counters) == 0:
+ return counters
+
count = reduce(lambda x, y: x + y, counters)
return [x for x in count.keys() if count[x] == 1]
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