[yt-svn] commit/yt: atmyers: Merged in MatthewTurk/yt (pull request #2243)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Jun 17 07:34:59 PDT 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/27783a435b49/
Changeset:   27783a435b49
Branch:      yt
User:        atmyers
Date:        2016-06-17 14:34:41+00:00
Summary:     Merged in MatthewTurk/yt (pull request #2243)

Check that CIC always gets at least two cells.  Closes #1057.
Affected #:  3 files

diff -r 5da31254f065d004d45d5e182f674f1cce9ea57f -r 27783a435b496c47db10e1a1f5f5f1485ab2bcf1 yt/geometry/particle_deposit.pyx
--- a/yt/geometry/particle_deposit.pyx
+++ b/yt/geometry/particle_deposit.pyx
@@ -329,6 +329,11 @@
     cdef np.float64_t[:,:,:,:] field
     cdef public object ofield
     def initialize(self):
+        if not all(_ > 1 for _ in self.nvals):
+            from yt.utilities.exceptions import YTBoundsDefinitionError
+            raise YTBoundsDefinitionError(
+                "CIC requires minimum of 2 zones in all dimensions",
+                self.nvals)
         self.field = append_axes(
             np.zeros(self.nvals, dtype="float64", order='F'), 4)
 

diff -r 5da31254f065d004d45d5e182f674f1cce9ea57f -r 27783a435b496c47db10e1a1f5f5f1485ab2bcf1 yt/geometry/tests/test_particle_deposit.py
--- /dev/null
+++ b/yt/geometry/tests/test_particle_deposit.py
@@ -0,0 +1,14 @@
+from yt.utilities.exceptions import \
+    YTBoundsDefinitionError
+
+from yt.testing import \
+    fake_random_ds
+from numpy.testing import \
+    assert_raises
+
+def test_cic_deposit():
+    ds = fake_random_ds(64, nprocs = 8, particles=64**3)
+    my_reg = ds.arbitrary_grid(ds.domain_left_edge, ds.domain_right_edge,
+            dims=[1, 800, 800])
+    f = ("deposit", "all_cic")
+    assert_raises(YTBoundsDefinitionError, my_reg.__getitem__, f)

diff -r 5da31254f065d004d45d5e182f674f1cce9ea57f -r 27783a435b496c47db10e1a1f5f5f1485ab2bcf1 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -568,3 +568,14 @@
         v = "This operation is not supported for data of geometry %s; " % self.this
         v += "It supports data of geometries %s" % (self.supported,)
         return v
+
+class YTBoundsDefinitionError(YTException):
+    def __init__(self, message, bounds):
+        self.bounds = bounds
+        self.message = message
+
+    def __str__(self):
+        v  = "This operation has encountered a bounds error: "
+        v += self.message
+        v += " Specified bounds are %s" % self.bounds
+        return v

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