[yt-svn] commit/yt: xarthisius: Merged in ngoldbaum/yt (pull request #1991)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Feb 17 09:08:44 PST 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/0f22947ebba1/
Changeset:   0f22947ebba1
Branch:      yt
User:        xarthisius
Date:        2016-02-17 17:08:29+00:00
Summary:     Merged in ngoldbaum/yt (pull request #1991)

Fix issues with input sanitization in the point data object
Affected #:  2 files

diff -r e494c777c38a524533614eebe200c7c5c7c55cc1 -r 0f22947ebba119f8039037937270e295d95224a7 yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -69,7 +69,11 @@
     _con_args = ('p',)
     def __init__(self, p, ds=None, field_parameters=None, data_source=None):
         super(YTPoint, self).__init__(ds, field_parameters, data_source)
-        self.p = p
+        if isinstance(p, YTArray):
+            # we pass p through ds.arr to ensure code units are attached
+            self.p = self.ds.arr(p)
+        else:
+            self.p = self.ds.arr(p, 'code_length')
 
 class YTOrthoRay(YTSelectionContainer1D):
     """

diff -r e494c777c38a524533614eebe200c7c5c7c55cc1 -r 0f22947ebba119f8039037937270e295d95224a7 yt/data_objects/tests/test_points.py
--- a/yt/data_objects/tests/test_points.py
+++ b/yt/data_objects/tests/test_points.py
@@ -10,6 +10,17 @@
     from yt.config import ytcfg
     ytcfg["yt","__withintesting"] = "True"
 
+def test_point_creation():
+    ds = fake_random_ds(16)
+    p1 = ds.point(ds.domain_center)
+    p2 = ds.point([0.5, 0.5, 0.5])
+    p3 = ds.point([0.5, 0.5, 0.5]*yt.units.cm)
+
+    # ensure all three points are really at the same position
+    for fname in 'xyz':
+        assert_equal(p1[fname], p2[fname])
+        assert_equal(p1[fname], p3[fname])
+
 def test_domain_point():
     nparticles = 3
     ds = fake_random_ds(16, particles=nparticles)

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