[yt-svn] commit/yt: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Mar 18 04:37:17 PDT 2013
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/d07cd0907966/
changeset: d07cd0907966
branch: yt
user: xarthisius
date: 2013-03-16 16:03:29
summary: [test_pickle] use tempfile, add license, pep8, add test description
affected #: 1 file
diff -r 5b79077a918d2c91fd74b734946138d81dbd83d5 -r d07cd090796667dee3970968eda4938a7aa2183a yt/data_objects/tests/test_pickle.py
--- a/yt/data_objects/tests/test_pickle.py
+++ b/yt/data_objects/tests/test_pickle.py
@@ -1,8 +1,33 @@
-from yt.testing import fake_random_pf, assert_equal
-from yt.analysis_modules.level_sets.api import identify_contours
-import yt.data_objects.api
+"""
+Testsuite for pickling yt objects.
+
+Author: Elizabeth Tasker <tasker at astro1.sci.hokudai.ac.jp>
+Affiliation: Hokkaido University
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2013 Elizabeth Tasker. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
import cPickle
import os
+import tempfile
+from yt.testing \
+ import fake_random_pf, assert_equal
+
def setup():
"""Test specific setup."""
@@ -11,27 +36,34 @@
def test_save_load_pickle():
-
- pf = fake_random_pf(64)
+ """Main test for loading pickled objects"""
+ test_pf = fake_random_pf(64)
# create extracted region from boolean (fairly complex object)
- center = (pf.domain_left_edge + pf.domain_right_edge) / 2
- sp_outer = pf.h.sphere(center, pf.domain_width[0])
- sp_inner = pf.h.sphere(center, pf.domain_width[0]/10.0)
- sp_boolean = pf.h.boolean([sp_outer, "NOT", sp_inner])
+ center = (test_pf.domain_left_edge + test_pf.domain_right_edge) / 2
+ sp_outer = test_pf.h.sphere(center, test_pf.domain_width[0])
+ sp_inner = test_pf.h.sphere(center, test_pf.domain_width[0] / 10.0)
+ sp_boolean = test_pf.h.boolean([sp_outer, "NOT", sp_inner])
minv, maxv = sp_boolean.quantities["Extrema"]("Density")[0]
- contour_threshold = min(minv*10, 0.9*maxv)
-
- contours = sp_boolean.extract_connected_sets("Density", 1, contour_threshold, maxv+1, log_space=True, cache=True)
+ contour_threshold = min(minv * 10.0, 0.9 * maxv)
+
+ contours = sp_boolean.extract_connected_sets(
+ "Density", 1, contour_threshold, maxv + 1, log_space=True, cache=True)
# save object
- cPickle.dump(contours[1][0], open("myobject.cpkl", "wb"))
-
+ cpklfile = tempfile.NamedTemporaryFile(delete=False)
+ cPickle.dump(contours[1][0], cpklfile)
+ cpklfile.close()
+
# load object
- test_load = cPickle.load(open("myobject.cpkl", "rb"))
+ test_load = cPickle.load(open(cpklfile.name, "rb"))
- yield assert_equal, test_load != None, True
+ assert_equal.description = \
+ "%s: File was pickle-loaded succesfully" % __name__
+ yield assert_equal, test_load is not None, True
+ assert_equal.description = \
+ "%s: Length of pickle-loaded connected set object" % __name__
yield assert_equal, len(contours[1][0]), len(test_load)
- os.remove("myobject.cpkl")
+ os.remove(cpklfile.name)
https://bitbucket.org/yt_analysis/yt/commits/37e33227a70d/
changeset: 37e33227a70d
branch: yt
user: MatthewTurk
date: 2013-03-18 12:37:14
summary: Merged in xarthisius/yt (pull request #464)
[test_pickle] use tempfile, add license, pep8, add test description
affected #: 1 file
diff -r b7e6a954277064a0cf50f17b93142e0dd72bd8e2 -r 37e33227a70d4db04d9715aaa195d1b5e6859c9f yt/data_objects/tests/test_pickle.py
--- a/yt/data_objects/tests/test_pickle.py
+++ b/yt/data_objects/tests/test_pickle.py
@@ -1,8 +1,33 @@
-from yt.testing import fake_random_pf, assert_equal
-from yt.analysis_modules.level_sets.api import identify_contours
-import yt.data_objects.api
+"""
+Testsuite for pickling yt objects.
+
+Author: Elizabeth Tasker <tasker at astro1.sci.hokudai.ac.jp>
+Affiliation: Hokkaido University
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2013 Elizabeth Tasker. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
import cPickle
import os
+import tempfile
+from yt.testing \
+ import fake_random_pf, assert_equal
+
def setup():
"""Test specific setup."""
@@ -11,27 +36,34 @@
def test_save_load_pickle():
-
- pf = fake_random_pf(64)
+ """Main test for loading pickled objects"""
+ test_pf = fake_random_pf(64)
# create extracted region from boolean (fairly complex object)
- center = (pf.domain_left_edge + pf.domain_right_edge) / 2
- sp_outer = pf.h.sphere(center, pf.domain_width[0])
- sp_inner = pf.h.sphere(center, pf.domain_width[0]/10.0)
- sp_boolean = pf.h.boolean([sp_outer, "NOT", sp_inner])
+ center = (test_pf.domain_left_edge + test_pf.domain_right_edge) / 2
+ sp_outer = test_pf.h.sphere(center, test_pf.domain_width[0])
+ sp_inner = test_pf.h.sphere(center, test_pf.domain_width[0] / 10.0)
+ sp_boolean = test_pf.h.boolean([sp_outer, "NOT", sp_inner])
minv, maxv = sp_boolean.quantities["Extrema"]("Density")[0]
- contour_threshold = min(minv*10, 0.9*maxv)
-
- contours = sp_boolean.extract_connected_sets("Density", 1, contour_threshold, maxv+1, log_space=True, cache=True)
+ contour_threshold = min(minv * 10.0, 0.9 * maxv)
+
+ contours = sp_boolean.extract_connected_sets(
+ "Density", 1, contour_threshold, maxv + 1, log_space=True, cache=True)
# save object
- cPickle.dump(contours[1][0], open("myobject.cpkl", "wb"))
-
+ cpklfile = tempfile.NamedTemporaryFile(delete=False)
+ cPickle.dump(contours[1][0], cpklfile)
+ cpklfile.close()
+
# load object
- test_load = cPickle.load(open("myobject.cpkl", "rb"))
+ test_load = cPickle.load(open(cpklfile.name, "rb"))
- yield assert_equal, test_load != None, True
+ assert_equal.description = \
+ "%s: File was pickle-loaded succesfully" % __name__
+ yield assert_equal, test_load is not None, True
+ assert_equal.description = \
+ "%s: Length of pickle-loaded connected set object" % __name__
yield assert_equal, len(contours[1][0]), len(test_load)
- os.remove("myobject.cpkl")
+ os.remove(cpklfile.name)
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