Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding testcases for visualization.image_writer #1842

Merged
merged 3 commits into from Jul 3, 2018

Conversation

git-abhishek
Copy link
Contributor

PR Summary

Adding testcases for visualization.image_writer

PR Checklist

  • Code passes flake8 checker
  • New features are documented, with docstrings and narrative docs NA
  • Adds a test for any bugs fixed. Adds tests for new features. NA

Adding Reviewers

@ngoldbaum @Xarthisius @colinmarc

if len(bitmap_array.shape) != 3 or bitmap_array.shape[-1] not in (3,4):
raise RuntimeError
if len(bitmap_array.shape) != 3 or bitmap_array.shape[-1] not in (3, 4):
raise YTException(message="Expecting image array of shape (N,M,3)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just use RuntimeError instead of YTException here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -295,8 +299,8 @@ def strip_colormap_data(fn = "color_map_data.py",
f.write("from numpy import array\n")
f.write("color_map_luts = {}\n\n\n")
if cmaps is None: cmaps = rcm.ColorMaps
if isinstance(cmaps, string_types): cmaps = [cmaps]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

carriage return after the colon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if suffix == ".png":
canvas = FigureCanvasAgg(fig)
elif suffix == ".pdf":
if suffix == ".pdf":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you restore the logic that was originally here? We want the warning message about the unknown suffix I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_image_suffix(filename) returns ['.png', '.eps', '.ps', '.pdf', ''] thus, it will never execute the original else block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fair enough

import tempfile
import unittest

from yt.mods import write_projection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import this from yt.visualization.image_writer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

# Test remaining parameters of write_projection
write_projection(image, "test_2", xlabel="x-axis", ylabel="y-axis")
write_projection(image, "test_3.pdf", xlabel="x-axis", ylabel="y-axis")
write_projection(image, "test_4.eps", xlabel="x-axis", ylabel="y-axis")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test to make sure these images are actually written to disk and are in the correct format? See the assert_fname function in yt.testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor Author

@git-abhishek git-abhishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as per the first code review.

if len(bitmap_array.shape) != 3 or bitmap_array.shape[-1] not in (3,4):
raise RuntimeError
if len(bitmap_array.shape) != 3 or bitmap_array.shape[-1] not in (3, 4):
raise YTException(message="Expecting image array of shape (N,M,3)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -295,8 +299,8 @@ def strip_colormap_data(fn = "color_map_data.py",
f.write("from numpy import array\n")
f.write("color_map_luts = {}\n\n\n")
if cmaps is None: cmaps = rcm.ColorMaps
if isinstance(cmaps, string_types): cmaps = [cmaps]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

import tempfile
import unittest

from yt.mods import write_projection
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

# Test remaining parameters of write_projection
write_projection(image, "test_2", xlabel="x-axis", ylabel="y-axis")
write_projection(image, "test_3.pdf", xlabel="x-axis", ylabel="y-axis")
write_projection(image, "test_4.eps", xlabel="x-axis", ylabel="y-axis")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@ngoldbaum
Copy link
Member

@yt-fido test this please

1 similar comment
@ngoldbaum
Copy link
Member

@yt-fido test this please

@ngoldbaum ngoldbaum merged commit 0c5a993 into yt-project:master Jul 3, 2018
@git-abhishek git-abhishek deleted the viz-image-writer branch July 9, 2018 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants