[yt-svn] commit/yt: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Oct 14 14:05:36 PDT 2015
4 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/40a43a6806ae/
Changeset: 40a43a6806ae
Branch: yt
User: atmyers
Date: 2015-09-24 23:13:13+00:00
Summary: fixing the add method of zbuffer
Affected #: 1 file
diff -r 52b57ac913dd7e334914c7e8985f35ebb1618346 -r 40a43a6806aebef34d902388db44e424b528334a yt/visualization/volume_rendering/zbuffer_array.py
--- a/yt/visualization/volume_rendering/zbuffer_array.py
+++ b/yt/visualization/volume_rendering/zbuffer_array.py
@@ -28,13 +28,16 @@
def __add__(self, other):
assert(self.shape == other.shape)
- f_or_b = self.z < other.z
+ f = self.z < other.z
+ use_self = np.dstack((f, f, f, f))
+ b = self.z > other.z
+ use_other = np.dstack((b, b, b, b))
if self.z.shape[1] == 1:
# Non-rectangular
- rgba = (self.rgba * f_or_b[:,None,:])
- rgba += (other.rgba * (1.0 - f_or_b)[:,None,:])
+ rgba = (self.rgba * f[:,None,:])
+ rgba += (other.rgba * (1.0 - f)[:,None,:])
else:
- rgba = (self.rgba.T * f_or_b).T + (other.rgba.T * (1 - f_or_b)).T
+ rgba = self.rgba*use_self + other.rgba*use_other
z = np.min([self.z, other.z], axis=0)
return ZBuffer(rgba, z)
https://bitbucket.org/yt_analysis/yt/commits/c987c558e26a/
Changeset: c987c558e26a
Branch: yt
User: atmyers
Date: 2015-09-25 19:05:25+00:00
Summary: unit tests for the zbuffer add operation
Affected #: 1 file
diff -r 40a43a6806aebef34d902388db44e424b528334a -r c987c558e26aae0177c1cff7531c5f667486c436 yt/visualization/volume_rendering/tests/test_zbuff.py
--- a/yt/visualization/volume_rendering/tests/test_zbuff.py
+++ b/yt/visualization/volume_rendering/tests/test_zbuff.py
@@ -10,15 +10,15 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-import yt
from yt.testing import fake_random_ds
-from yt.visualization.volume_rendering.api import Scene, Camera, ZBuffer, \
- VolumeSource, OpaqueSource, LineSource, BoxSource
-from yt.utilities.lib.misc_utilities import lines
-from yt.data_objects.api import ImageArray
+from yt.visualization.volume_rendering.api import \
+ Scene, Camera, ZBuffer, \
+ VolumeSource, OpaqueSource
+from yt.testing import assert_almost_equal
import numpy as np
np.random.seed(0)
+
def test_composite_vr():
ds = fake_random_ds(64)
dd = ds.sphere(ds.domain_center, 0.45*ds.domain_width[0])
@@ -53,5 +53,55 @@
im.write_png("composite.png")
return im
+
+def test_nonrectangular_add():
+ rgba1 = np.ones((64, 1, 4))
+ z1 = np.expand_dims(np.arange(64.), 1)
+
+ rgba2 = np.zeros((64, 1, 4))
+ z2 = np.expand_dims(np.arange(63., -1., -1.), 1)
+
+ exact_rgba = np.concatenate((np.ones(32), np.zeros(32)))
+ exact_rgba = np.expand_dims(exact_rgba, 1)
+ exact_rgba = np.dstack((exact_rgba, exact_rgba, exact_rgba, exact_rgba))
+
+ exact_z = np.concatenate((np.arange(32.), np.arange(31.,-1.,-1.)))
+ exact_z = np.expand_dims(exact_z, 1)
+
+ buff1 = ZBuffer(rgba1, z1)
+ buff2 = ZBuffer(rgba2, z2)
+
+ buff = buff1 + buff2
+
+ assert_almost_equal(buff.rgba, exact_rgba)
+ assert_almost_equal(buff.z, exact_z)
+
+
+def test_rectangular_add():
+ rgba1 = np.ones((8, 8, 4))
+ z1 = np.arange(64.)
+ z1 = z1.reshape((8, 8))
+ buff1 = ZBuffer(rgba1, z1)
+
+ rgba2 = np.zeros((8, 8, 4))
+ z2 = np.arange(63., -1., -1.)
+ z2 = z2.reshape((8, 8))
+ buff2 = ZBuffer(rgba2, z2)
+
+ buff = buff1 + buff2
+
+ exact_rgba = np.empty((8, 8, 4), dtype=np.float64)
+ exact_rgba[0:4,0:8,:] = 1.0
+ exact_rgba[4:8,0:8,:] = 0.0
+
+ exact_z = np.concatenate((np.arange(32.), np.arange(31., -1., -1.)))
+ exact_z = np.expand_dims(exact_z, 1)
+ exact_z = exact_z.reshape(8, 8)
+
+ assert_almost_equal(buff.rgba, exact_rgba)
+ assert_almost_equal(buff.z, exact_z)
+
if __name__ == "__main__":
im = test_composite_vr()
+ test_nonrectangular_add()
+ test_rectangular_add()
https://bitbucket.org/yt_analysis/yt/commits/0f4162a5d182/
Changeset: 0f4162a5d182
Branch: yt
User: atmyers
Date: 2015-10-14 18:27:05+00:00
Summary: a more memory-efficient implementation of zbuffer add
Affected #: 1 file
diff -r c987c558e26aae0177c1cff7531c5f667486c436 -r 0f4162a5d18215d7206caef7369384be6a3d5fba yt/visualization/volume_rendering/zbuffer_array.py
--- a/yt/visualization/volume_rendering/zbuffer_array.py
+++ b/yt/visualization/volume_rendering/zbuffer_array.py
@@ -29,15 +29,15 @@
def __add__(self, other):
assert(self.shape == other.shape)
f = self.z < other.z
- use_self = np.dstack((f, f, f, f))
- b = self.z > other.z
- use_other = np.dstack((b, b, b, b))
if self.z.shape[1] == 1:
# Non-rectangular
rgba = (self.rgba * f[:,None,:])
rgba += (other.rgba * (1.0 - f)[:,None,:])
else:
- rgba = self.rgba*use_self + other.rgba*use_other
+ b = self.z > other.z
+ rgba = np.empty(self.rgba.shape)
+ rgba[f] = self.rgba[f]
+ rgba[b] = other.rgba[b]
z = np.min([self.z, other.z], axis=0)
return ZBuffer(rgba, z)
https://bitbucket.org/yt_analysis/yt/commits/f5b180206fa3/
Changeset: f5b180206fa3
Branch: yt
User: ngoldbaum
Date: 2015-10-14 21:05:27+00:00
Summary: Merged in atmyers/yt (pull request #1792)
[Experimental] [Bugfix] Fixing the add operation of Zbuffer
Affected #: 2 files
diff -r d3ba9ef67a78946c1a0afe6a455310991a228f9f -r f5b180206fa30adb2213221a3e09a96e99bb866e yt/visualization/volume_rendering/tests/test_zbuff.py
--- a/yt/visualization/volume_rendering/tests/test_zbuff.py
+++ b/yt/visualization/volume_rendering/tests/test_zbuff.py
@@ -10,15 +10,15 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-import yt
from yt.testing import fake_random_ds
-from yt.visualization.volume_rendering.api import Scene, Camera, ZBuffer, \
- VolumeSource, OpaqueSource, LineSource, BoxSource
-from yt.utilities.lib.misc_utilities import lines
-from yt.data_objects.api import ImageArray
+from yt.visualization.volume_rendering.api import \
+ Scene, Camera, ZBuffer, \
+ VolumeSource, OpaqueSource
+from yt.testing import assert_almost_equal
import numpy as np
np.random.seed(0)
+
def test_composite_vr():
ds = fake_random_ds(64)
dd = ds.sphere(ds.domain_center, 0.45*ds.domain_width[0])
@@ -53,5 +53,55 @@
im.write_png("composite.png")
return im
+
+def test_nonrectangular_add():
+ rgba1 = np.ones((64, 1, 4))
+ z1 = np.expand_dims(np.arange(64.), 1)
+
+ rgba2 = np.zeros((64, 1, 4))
+ z2 = np.expand_dims(np.arange(63., -1., -1.), 1)
+
+ exact_rgba = np.concatenate((np.ones(32), np.zeros(32)))
+ exact_rgba = np.expand_dims(exact_rgba, 1)
+ exact_rgba = np.dstack((exact_rgba, exact_rgba, exact_rgba, exact_rgba))
+
+ exact_z = np.concatenate((np.arange(32.), np.arange(31.,-1.,-1.)))
+ exact_z = np.expand_dims(exact_z, 1)
+
+ buff1 = ZBuffer(rgba1, z1)
+ buff2 = ZBuffer(rgba2, z2)
+
+ buff = buff1 + buff2
+
+ assert_almost_equal(buff.rgba, exact_rgba)
+ assert_almost_equal(buff.z, exact_z)
+
+
+def test_rectangular_add():
+ rgba1 = np.ones((8, 8, 4))
+ z1 = np.arange(64.)
+ z1 = z1.reshape((8, 8))
+ buff1 = ZBuffer(rgba1, z1)
+
+ rgba2 = np.zeros((8, 8, 4))
+ z2 = np.arange(63., -1., -1.)
+ z2 = z2.reshape((8, 8))
+ buff2 = ZBuffer(rgba2, z2)
+
+ buff = buff1 + buff2
+
+ exact_rgba = np.empty((8, 8, 4), dtype=np.float64)
+ exact_rgba[0:4,0:8,:] = 1.0
+ exact_rgba[4:8,0:8,:] = 0.0
+
+ exact_z = np.concatenate((np.arange(32.), np.arange(31., -1., -1.)))
+ exact_z = np.expand_dims(exact_z, 1)
+ exact_z = exact_z.reshape(8, 8)
+
+ assert_almost_equal(buff.rgba, exact_rgba)
+ assert_almost_equal(buff.z, exact_z)
+
if __name__ == "__main__":
im = test_composite_vr()
+ test_nonrectangular_add()
+ test_rectangular_add()
diff -r d3ba9ef67a78946c1a0afe6a455310991a228f9f -r f5b180206fa30adb2213221a3e09a96e99bb866e yt/visualization/volume_rendering/zbuffer_array.py
--- a/yt/visualization/volume_rendering/zbuffer_array.py
+++ b/yt/visualization/volume_rendering/zbuffer_array.py
@@ -28,13 +28,16 @@
def __add__(self, other):
assert(self.shape == other.shape)
- f_or_b = self.z < other.z
+ f = self.z < other.z
if self.z.shape[1] == 1:
# Non-rectangular
- rgba = (self.rgba * f_or_b[:,None,:])
- rgba += (other.rgba * (1.0 - f_or_b)[:,None,:])
+ rgba = (self.rgba * f[:,None,:])
+ rgba += (other.rgba * (1.0 - f)[:,None,:])
else:
- rgba = (self.rgba.T * f_or_b).T + (other.rgba.T * (1 - f_or_b)).T
+ b = self.z > other.z
+ rgba = np.empty(self.rgba.shape)
+ rgba[f] = self.rgba[f]
+ rgba[b] = other.rgba[b]
z = np.min([self.z, other.z], axis=0)
return ZBuffer(rgba, z)
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