text
stringlengths
0
828
np.sign(n)*nret*10.**exp)"
791,"def convert_radian(coord, *variables):
""""""Convert the given coordinate from radian to degree
Parameters
----------
coord: xr.Variable
The variable to transform
``*variables``
The variables that are on the same unit.
Returns
-------
xr.Variable
The transformed variable if one of the given `variables` has units in
radian""""""
if any(v.attrs.get('units') == 'radian' for v in variables):
return coord * 180. / np.pi
return coord"
792,"def format_coord_func(ax, ref):
""""""Create a function that can replace the
:func:`matplotlib.axes.Axes.format_coord`
Parameters
----------
ax: matplotlib.axes.Axes
The axes instance
ref: weakref.weakref
The reference to the :class:`~psyplot.plotter.Formatoption` instance
Returns
-------
function
The function that can be used to replace `ax.format_coord`
""""""
orig_format_coord = ax.format_coord
def func(x, y):
orig_s = orig_format_coord(x, y)
fmto = ref()
if fmto is None:
return orig_s
try:
orig_s += fmto.add2format_coord(x, y)
except Exception:
fmto.logger.debug(
'Failed to get plot informations for status bar!', exc_info=1)
return orig_s
return func"
793,"def replace_coord(self, i):
""""""Replace the coordinate for the data array at the given position
Parameters
----------
i: int
The number of the data array in the raw data (if the raw data is
not an interactive list, use 0)
Returns
xarray.DataArray
The data array with the replaced coordinate""""""
da = next(islice(self.data_iterator, i, i+1))
name, coord = self.get_alternative_coord(da, i)
other_coords = {key: da.coords[key]
for key in set(da.coords).difference(da.dims)}
ret = da.rename({da.dims[-1]: name}).assign_coords(
**{name: coord}).assign_coords(**other_coords)
return ret"
794,"def value2pickle(self):
""""""Return the current axis colors""""""
return {key: s.get_edgecolor() for key, s in self.ax.spines.items()}"
795,"def set_default_formatters(self, which=None):
""""""Sets the default formatters that is used for updating to None
Parameters
----------
which: {None, 'minor', 'major'}
Specify which locator shall be set""""""
if which is None or which == 'minor':
self.default_formatters['minor'] = self.axis.get_minor_formatter()
if which is None or which == 'major':
self.default_formatters['major'] = self.axis.get_major_formatter()"
796,"def plotted_data(self):
""""""The data that is shown to the user""""""
return InteractiveList(
[arr for arr, val in zip(self.iter_data,
cycle(slist(self.value)))
if val is not None])"
797,"def get_cmap(self, arr=None, cmap=None, N=None):
""""""Get the :class:`matplotlib.colors.Colormap` for plotting
Parameters
----------
arr: np.ndarray
The array to plot
cmap: str or matplotlib.colors.Colormap
The colormap to use. If None, the :attr:`value` of this
formatoption is used
N: int