Skip to content

Commit

Permalink
PEP8 changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRyanIrish committed Apr 9, 2018
1 parent 2a90458 commit 6f2746a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions ndcube/mixins/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import sunpy.visualization.wcsaxes_compat as wcsaxes_compat

from ndcube import utils
from ndcube.mixins.sequence_plotting import _prep_axes_kwargs, _derive_1D_coordinates_and_units, _determine_sequence_units, _make_1D_sequence_plot
from ndcube.mixins import sequence_plotting
from ndcube.mixins.sequence_plotting import

__all__ = ['NDCubePlotMixin']

Expand Down Expand Up @@ -65,18 +66,18 @@ def plot(self, axes=None, plot_axis_indices=None, axes_coordinates=None,
plot_axis_indices, axes_coordinates, axes_units, data_unit, kwargs)
# Check kwargs are in consistent formats and set default values if not done so by user.
naxis = len(self.dimensions)
plot_axis_indices, axes_coordinates, axes_units = _prep_axes_kwargs(
plot_axis_indices, axes_coordinates, axes_units = sequence_plotting._prep_axes_kwargs(
naxis, plot_axis_indices, axes_coordinates, axes_units)
if naxis is 1:
ax = self._plot_1D_cube(axes, axes_coordinates,
axes_units, data_unit, **kwargs)
axes_units, data_unit, **kwargs)
else:
if len(plot_axis_indices) == 1:
raise NotImplementedError()
else:
if naxis == 2:
ax = self._plot_2D_cube(axes, plot_axis_indices, axes_coordinates,
axes_units, data_unit, **kwargs)
axes_units, data_unit, **kwargs)
else:
ax = self._plot_3D_cube(
plot_axis_indices=plot_axis_indices, axes_coordinates=axes_coordinates,
Expand All @@ -96,8 +97,8 @@ def _plot_1D_cube(self, axes=None, axes_coordinates=None, axes_units=None, data_
"""
# Derive x-axis coordinates and unit from inputs.
x_axis_coordinates, unit_x_axis = _derive_1D_coordinates_and_units(axes_coordinates,
axes_units)
x_axis_coordinates, unit_x_axis = sequence_plotting._derive_1D_coordinates_and_units(
axes_coordinates, axes_units)
if x_axis_coordinates is None:
# Default is to derive x coords and defaul xlabel from WCS object.
xname = self.world_axis_physical_types[0]
Expand Down Expand Up @@ -154,7 +155,8 @@ def _plot_1D_cube(self, axes=None, axes_coordinates=None, axes_units=None, data_
if yerror is not None:
yerror = np.ma.masked_array(yerror, self.mask)
# Create plot
fig, ax = _make_1D_sequence_plot(xdata, ydata, yerror, data_unit, default_xlabel, kwargs)
fig, ax = sequence_plotting._make_1D_sequence_plot(xdata, ydata, yerror,
data_unit, default_xlabel, kwargs)
return ax

def _plot_2D_cube(self, axes=None, plot_axis_indices=None, axes_coordinates=None,
Expand Down Expand Up @@ -215,12 +217,12 @@ def _plot_2D_cube(self, axes=None, plot_axis_indices=None, axes_coordinates=None
ax = wcsaxes_compat.gca_wcs(self.wcs, slices=slice_list)
# Set axis labels
x_wcs_axis = utils.cube.data_axis_to_wcs_axis(plot_axis_indices[0],
self.missing_axis)
self.missing_axis)
ax.set_xlabel("{0} [{1}]".format(
self.world_axis_physical_types[plot_axis_indices[0]],
self.wcs.wcs.cunit[x_wcs_axis]))
y_wcs_axis = utils.cube.data_axis_to_wcs_axis(plot_axis_indices[1],
self.missing_axis)
self.missing_axis)
ax.set_ylabel("{0} [{1}]".format(
self.world_axis_physical_types[plot_axis_indices[1]],
self.wcs.wcs.cunit[y_wcs_axis]))
Expand Down Expand Up @@ -304,7 +306,7 @@ def _plot_3D_cube(self, plot_axis_indices=None, axes_coordinates=None,
# If axes_coordinates not provided generate an ImageAnimatorWCS plot
# using NDCube's wcs object.
if (axes_coordinates[plot_axis_indices[0]] is None and
axes_coordinates[plot_axis_indices[1]] is None):
axes_coordinates[plot_axis_indices[1]] is None):
# If there are missing axes in WCS object, add corresponding dummy axes to data.
if data.ndim < self.wcs.naxis:
new_shape = list(data.shape)
Expand Down Expand Up @@ -374,7 +376,7 @@ def _derive_axes_coordinates(self, axes_coordinates, axes_units):
raise TypeError(INVALID_UNIT_SET_MESSAGE)
# Derive default axis label
if type(new_axis_coordinate[0]) is datetime.datetime:
if axis_label_text == default_label_text:
if axis_label_text == default_label_text:
default_label = "{0}".format(new_axis_coordinate[0].strftime("%Y/%m/%d %H:%M"))
else:
default_label = "{0} [{1}]".format(
Expand Down
2 changes: 1 addition & 1 deletion ndcube/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
('another time', 2, np.array(
[datetime.datetime(2000, 1, 1)+datetime.timedelta(minutes=i)
for i in range(data.shape[2])]))
])
])


@pytest.mark.parametrize("test_input, test_kwargs, expected_values", [
Expand Down

0 comments on commit 6f2746a

Please sign in to comment.