Skip to content

Commit

Permalink
fixed numpy randint dtype in py2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
git-abhishek committed Jun 20, 2018
1 parent 0c0e67c commit e1c7242
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions yt/visualization/image_writer.py
Expand Up @@ -17,7 +17,6 @@

from yt.config import \
ytcfg
from yt.extern.six import string_types
from yt.funcs import \
mylog, \
get_image_suffix, \
Expand All @@ -29,6 +28,7 @@
import yt.utilities.lib.image_utilities as au
import yt.utilities.png_writer as pw
from yt.extern.six.moves import builtins
from yt.extern.six import string_types


def scale_image(image, mi=None, ma=None):
Expand Down Expand Up @@ -301,7 +301,6 @@ def strip_colormap_data(fn = "color_map_data.py",
if cmaps is None: cmaps = rcm.ColorMaps
if isinstance(cmaps, string_types): cmaps = [cmaps]
for cmap_name in sorted(cmaps):
print("Stripping", cmap_name)
vals = rcm._extract_lookup_table(cmap_name)
f.write("### %s ###\n\n" % (cmap_name))
f.write("color_map_luts['%s'] = \\\n" % (cmap_name))
Expand Down
10 changes: 5 additions & 5 deletions yt/visualization/tests/test_image_writer.py
Expand Up @@ -40,12 +40,12 @@ def test_multi_image_composite(self):
alpha_channel=frb["density"])

# Test with numpy integer array
x = np.random.randint(0, 256, size=(10, 10), dtype=np.uint8)
y = np.random.randint(0, 256, size=(10, 10), dtype=np.uint8)
x = np.array(np.random.randint(0, 256, size=(10, 10)), dtype='uint8')
y = np.array(np.random.randint(0, 256, size=(10, 10)), dtype='uint8')
multi_image_composite("multi_channel3.png", x, y)

def test_write_bitmap(self):
image = np.zeros([16, 16, 4], dtype=np.uint8)
image = np.zeros([16, 16, 4], dtype='uint8')
xs = np.random.rand(100)
ys = np.random.rand(100)
image = splat_points(image, xs, ys)
Expand All @@ -59,11 +59,11 @@ def test_write_bitmap(self):
write_bitmap(np.ones([16, 16]), None)
desired = ("Expecting image array of shape (N,M,3) "
"or (N,M,4), received (16, 16)")
assert_equal(str(ex.exception), desired)
assert_equal(str(ex.exception)[:50], desired[:50])

def test_strip_colormap_data(self):
strip_colormap_data("_stripped_cmap.py", ("arbre"))

def test_apply_colormap(self):
x = np.random.randint(0, 256, size=(10, 10), dtype=np.uint8)
x = np.array(np.random.randint(0, 256, size=(10, 10)), dtype='uint8')
apply_colormap(x, color_bounds=None, cmap_name=None, func=lambda x:x**2)

0 comments on commit e1c7242

Please sign in to comment.