Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _axes_getter(self, y):
if y in self._axes:
return y
if isinstance(y, basestring):
axes = list(self._get_axes_in_natural_order())
while axes:
axis = axes.pop()
if y == axis.name:
return axis
raise ValueError("There is no DataAxis named %s" % y)
elif (isfloat(y.real) and not y.real.is_integer() or
isfloat(y.imag) and not y.imag.is_integer()):
raise TypeError("axesmanager indices must be integers, "
"complex intergers or strings")
if y.imag == 0: # Natural order
return self._get_axes_in_natural_order()[y]
elif y.imag == 3: # Array order
# Array order
return self._axes[int(y.real)]
elif y.imag == 1: # Navigation natural order
#
return self.navigation_axes[int(y.real)]
elif y.imag == 2: # Signal natural order
return self.signal_axes[int(y.real)]
else:
raise IndexError("axesmanager imaginary part of complex indices "
"must be 0, 1 or 2")
def _axes_getter(self, y):
if y in self._axes:
return y
if isinstance(y, basestring):
axes = list(self._get_axes_in_natural_order())
while axes:
axis = axes.pop()
if y == axis.name:
return axis
raise ValueError("There is no DataAxis named %s" % y)
elif (isfloat(y.real) and not y.real.is_integer() or
isfloat(y.imag) and not y.imag.is_integer()):
raise TypeError("axesmanager indices must be integers, "
"complex intergers or strings")
if y.imag == 0: # Natural order
return self._get_axes_in_natural_order()[y]
elif y.imag == 3: # Array order
# Array order
return self._axes[int(y.real)]
elif y.imag == 1: # Navigation natural order
#
return self.navigation_axes[int(y.real)]
elif y.imag == 2: # Signal natural order
return self.signal_axes[int(y.real)]
else:
raise IndexError("axesmanager imaginary part of complex indices "
"must be 0, 1 or 2")
----------
slice_ : {float, int, slice}
Returns
-------
my_slice : slice
"""
v2i = self.value2index
if isinstance(slice_, slice):
start = slice_.start
stop = slice_.stop
step = slice_.step
else:
if isfloat(slice_):
start = v2i(slice_)
else:
start = self._get_positive_index(slice_)
stop = start + 1
step = None
if isfloat(step):
step = int(round(step / self.scale))
if isfloat(start):
try:
start = v2i(start)
except ValueError:
# The value is below the axis limits
# we slice from the start.
start = None
if isfloat(stop):
if isinstance(slice_, slice):
start = slice_.start
stop = slice_.stop
step = slice_.step
else:
if isfloat(slice_):
start = v2i(slice_)
else:
start = self._get_positive_index(slice_)
stop = start + 1
step = None
if isfloat(step):
step = int(round(step / self.scale))
if isfloat(start):
try:
start = v2i(start)
except ValueError:
# The value is below the axis limits
# we slice from the start.
start = None
if isfloat(stop):
try:
stop = v2i(stop)
except ValueError:
# The value is above the axes limits
# we slice up to the end.
stop = None
if step == 0:
raise ValueError("slice step cannot be zero")
"""
v2i = self.value2index
if isinstance(slice_, slice):
start = slice_.start
stop = slice_.stop
step = slice_.step
else:
if isfloat(slice_):
start = v2i(slice_)
else:
start = self._get_positive_index(slice_)
stop = start + 1
step = None
if isfloat(step):
step = int(round(step / self.scale))
if isfloat(start):
try:
start = v2i(start)
except ValueError:
# The value is below the axis limits
# we slice from the start.
start = None
if isfloat(stop):
try:
stop = v2i(stop)
except ValueError:
# The value is above the axes limits
# we slice up to the end.
stop = None
----------
slice_ : {float, int, slice}
Returns
-------
my_slice : slice
"""
v2i = self.value2index
if isinstance(slice_, slice):
start = slice_.start
stop = slice_.stop
step = slice_.step
else:
if isfloat(slice_):
start = v2i(slice_)
else:
start = self._get_positive_index(slice_)
stop = start + 1
step = None
if isfloat(step):
step = int(round(step / self.scale))
if isfloat(start):
try:
start = v2i(start)
except ValueError:
if start > self.high_value:
# The start value is above the axis limit
raise IndexError(
"Start value above axis high bound for axis %s."