diff --git a/sumpy/visualization.py b/sumpy/visualization.py index 3a4dc8df66512fdf1da8e5e3c40fa1794e0bcfad..bf5f016b4c089be7723a2ff92c91530c998603c2 100644 --- a/sumpy/visualization.py +++ b/sumpy/visualization.py @@ -64,35 +64,35 @@ def separate_by_real_and_imag(data, real_only): def make_field_plotter_from_bbox(bbox, h, extend_factor=0): - """ - :arg bbox: a tuple (low, high) of points represented as 1D numpy arrays - indicating the low and high ends of the extent of a bounding box. - :arg h: Either a number or a sequence of numbers indicating the desired - (approximate) grid spacing in all or each of the dimensions. If a - sequence, the length must match the number of dimensions. - :arg extend_factor: A floating point number indicating by what percentage - the plot area should be grown compared to *bbox*. - """ - low, high = bbox - - extent = (high-low) * (1 + extend_factor) - center = 0.5*(high+low) - - dimensions = len(center) - from numbers import Number - if isinstance(h, Number): - h = (h,)*dimensions - else: - if len(h) != dimensions: - raise ValueError("length of 'h' must match number of dimensions") + """ + :arg bbox: a tuple (low, high) of points represented as 1D numpy arrays + indicating the low and high ends of the extent of a bounding box. + :arg h: Either a number or a sequence of numbers indicating the desired + (approximate) grid spacing in all or each of the dimensions. If a + sequence, the length must match the number of dimensions. + :arg extend_factor: A floating point number indicating by what percentage + the plot area should be grown compared to *bbox*. + """ + low, high = bbox + + extent = (high-low) * (1 + extend_factor) + center = 0.5*(high+low) + + dimensions = len(center) + from numbers import Number + if isinstance(h, Number): + h = (h,)*dimensions + else: + if len(h) != dimensions: + raise ValueError("length of 'h' must match number of dimensions") - from math import ceil + from math import ceil - npoints = tuple( - int(ceil(extent[i] / h[i])) - for i in range(dimensions)) + npoints = tuple( + int(ceil(extent[i] / h[i])) + for i in range(dimensions)) - return FieldPlotter(center, extent, npoints) + return FieldPlotter(center, extent, npoints) class FieldPlotter(object):