[yt-svn] commit/yt: ngoldbaum: Cleaning up handling plot widths in plot_window.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu May 1 06:22:57 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/f228e5bea67d/
Changeset: f228e5bea67d
Branch: yt-3.0
User: ngoldbaum
Date: 2014-05-01 06:28:56
Summary: Cleaning up handling plot widths in plot_window.
Affected #: 2 files
diff -r 5affa74d80f34e32c9137bd4ed03821b7ac17570 -r f228e5bea67d968ec1ca2d2cc755883481b43dce yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -267,8 +267,8 @@
return s
class YTInvalidWidthError(YTException):
- def __init__(self, error):
- self.error = error
+ def __init__(self, width):
+ self.error = "width (%s) is invalid" % str(width)
def __str__(self):
return str(self.error)
diff -r 5affa74d80f34e32c9137bd4ed03821b7ac17570 -r f228e5bea67d968ec1ca2d2cc755883481b43dce yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -47,7 +47,9 @@
from yt.utilities.math_utils import \
ortho_find
from yt.utilities.exceptions import \
- YTUnitNotRecognized, YTInvalidWidthError, YTCannotParseUnitDisplayName
+ YTUnitNotRecognized, \
+ YTInvalidWidthError, \
+ YTCannotParseUnitDisplayName
from yt.data_objects.time_series import \
DatasetSeries
@@ -117,26 +119,24 @@
width = (w[0], w[1])
elif iterable(width):
width = validate_iterable_width(width, pf)
+ elif isinstance(width, YTQuantity):
+ width = (width, width)
+ elif isinstance(width, Number):
+ width = (pf.quan(width, 'code_length'),
+ pf.quan(width, 'code_length'))
else:
- try:
- assert isinstance(width, Number), \
- "width (%s) is invalid" % str(width)
- except AssertionError, e:
- raise YTInvalidWidthError(e)
- width = (pf.arr(width, 'code_length'),
- pf.arr(width, 'code_length'))
+ raise YTInvalidWidthError(width)
if depth is not None:
if iterable(depth):
assert_valid_width_tuple(depth)
- depth = (pf.quan(depth[0], fix_unitary(depth[1])),)
+ depth = (pf.quan(depth[0], fix_unitary(depth[1])), )
+ elif isinstance(depth, Number):
+ depth = (pf.quan(depth, 'code_length',
+ registry = pf.unit_registry), )
+ elif isinstance(depth, YTQuantity):
+ depth = (depth, )
else:
- try:
- assert isinstance(depth, Number), \
- "width (%s) is invalid" % str(depth)
- except AssertionError, e:
- raise YTInvalidWidthError(e)
- depth = (pf.quan(depth, 'code_length',
- registry = pf.unit_registry),)
+ raise YTInvalidWidthError(depth)
return width + depth
return width
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