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

Bitbucket commits-noreply at bitbucket.org
Wed Dec 19 04:24:16 PST 2012


2 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/f2605c9d8fa4/
changeset:   f2605c9d8fa4
branch:      yt
user:        xarthisius
date:        2012-12-18 20:49:16
summary:     Add test for GDF writer
affected #:  1 file

diff -r 4174ccdee99da445bf1a92919a3ae41abab53b2f -r f2605c9d8fa48a1ef447361a515027bb32d848b7 yt/utilities/grid_data_format/tests/test_writer.py
--- /dev/null
+++ b/yt/utilities/grid_data_format/tests/test_writer.py
@@ -0,0 +1,66 @@
+"""
+Testsuite for writing yt data to GDF
+
+Author: Kacper Kowalik <xarthisius.kk at gmail.com>
+Affiliation: Torun Center for Astronomy, NCU
+Homepage: http://yt-project.org/
+License:
+  Copyright (C) 2012 Kacper Kowalik.  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 tempfile
+import shutil
+import os
+import h5py as h5
+from yt.testing import \
+    fake_random_pf, assert_equal
+from yt.utilities.grid_data_format.writer import \
+    write_to_gdf
+from yt.frontends.gdf.data_structures import \
+    GDFStaticOutput
+from yt.mods import \
+    load
+
+TEST_AUTHOR = "yt test runner"
+TEST_COMMENT = "Testing write_to_gdf"
+
+
+def setup():
+    """Test specific setup."""
+    from yt.config import ytcfg
+    ytcfg["yt", "__withintesting"] = "True"
+
+
+def test_write_gdf():
+    """Main test suite for write_gdf"""
+    tmpdir = tempfile.mkdtemp()
+    tmpfile = os.path.join(tmpdir, 'test_gdf.h5')
+
+    test_pf = fake_random_pf(64)
+    write_to_gdf(test_pf, tmpfile, data_author=TEST_AUTHOR,
+                 data_comment=TEST_COMMENT)
+    del test_pf
+
+    assert isinstance(load(tmpfile), GDFStaticOutput)
+
+    h5f = h5.File(tmpfile, 'r')
+    gdf = h5f['gridded_data_format'].attrs
+    assert_equal(gdf['data_author'], TEST_AUTHOR)
+    assert_equal(gdf['data_comment'], TEST_COMMENT)
+    h5f.close()
+
+    shutil.rmtree(tmpdir)



https://bitbucket.org/yt_analysis/yt/changeset/38d19fd66171/
changeset:   38d19fd66171
branch:      yt
user:        MatthewTurk
date:        2012-12-19 13:24:15
summary:     Merged in xarthisius/yt (pull request #380: Add test for GDF writer)
affected #:  1 file

diff -r 5c47f8a3f9820c0ba71d53908c556803d12a47f9 -r 38d19fd66171bb88b0a4561420d304b078be6f95 yt/utilities/grid_data_format/tests/test_writer.py
--- /dev/null
+++ b/yt/utilities/grid_data_format/tests/test_writer.py
@@ -0,0 +1,66 @@
+"""
+Testsuite for writing yt data to GDF
+
+Author: Kacper Kowalik <xarthisius.kk at gmail.com>
+Affiliation: Torun Center for Astronomy, NCU
+Homepage: http://yt-project.org/
+License:
+  Copyright (C) 2012 Kacper Kowalik.  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 tempfile
+import shutil
+import os
+import h5py as h5
+from yt.testing import \
+    fake_random_pf, assert_equal
+from yt.utilities.grid_data_format.writer import \
+    write_to_gdf
+from yt.frontends.gdf.data_structures import \
+    GDFStaticOutput
+from yt.mods import \
+    load
+
+TEST_AUTHOR = "yt test runner"
+TEST_COMMENT = "Testing write_to_gdf"
+
+
+def setup():
+    """Test specific setup."""
+    from yt.config import ytcfg
+    ytcfg["yt", "__withintesting"] = "True"
+
+
+def test_write_gdf():
+    """Main test suite for write_gdf"""
+    tmpdir = tempfile.mkdtemp()
+    tmpfile = os.path.join(tmpdir, 'test_gdf.h5')
+
+    test_pf = fake_random_pf(64)
+    write_to_gdf(test_pf, tmpfile, data_author=TEST_AUTHOR,
+                 data_comment=TEST_COMMENT)
+    del test_pf
+
+    assert isinstance(load(tmpfile), GDFStaticOutput)
+
+    h5f = h5.File(tmpfile, 'r')
+    gdf = h5f['gridded_data_format'].attrs
+    assert_equal(gdf['data_author'], TEST_AUTHOR)
+    assert_equal(gdf['data_comment'], TEST_COMMENT)
+    h5f.close()
+
+    shutil.rmtree(tmpdir)

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