@property @tc.returns(tc.Optional(tuple)) def labels(self): """Returns the tuple containing coordinate labels, else None.""" return self._labels def index(self, value): """Returns the integer position of the given tick label.""" if self._index is None: raise ValueError('Axis does not have tick labels') return self._index[value] # tc class for anything that can be coerced into an Axis # pylint: disable=invalid-name AxisLike = tc.Union(Axis, tc.Tuple(string_types, AxisValue)) # pylint: enable=invalid-name @tc.returns(Axis) @tc.accepts(AxisLike) def as_axis(axis_data): """Convert an AxisLike object into an Axis. Args: axis_data: Axis object or tuple (axis_name, axis_value) describing an axis. Returns: Axis object. This may be the original object if axis_data is an Axis. """ if isinstance(axis_data, Axis):
@property @tc.returns(tc.Optional(tuple)) def labels(self): """Returns the tuple containing coordinate labels, else None.""" return self._labels def index(self, value): """Returns the integer position of the given tick label.""" if self._index is None: raise ValueError('Axis does not have tick labels') return self._index[value] # tc class for anything that can be coerced into an Axis # pylint: disable=invalid-name AxisLike = tc.Union(Axis, tc.Tuple(string_types, AxisValue)) # pylint: enable=invalid-name @tc.returns(Axis) @tc.accepts(AxisLike) def as_axis(axis_data): """Convert an AxisLike object into an Axis. Args: axis_data: Axis object or tuple (axis_name, axis_value) describing an axis. Returns: Axis object. This may be the original object if axis_data is an Axis. """ if isinstance(axis_data, Axis):
squeeze_dimensions.append(i) else: axes.append(axis) if squeeze_dimensions: squeeze_op = array_ops.squeeze(labeled_tensor.tensor, squeeze_dimensions, name=scope) else: squeeze_op = array_ops.identity(labeled_tensor.tensor, name=scope) return core.LabeledTensor(squeeze_op, axes) # pylint: disable=invalid-name ReduceAxis = tc.Union(string_types, tc.Tuple(string_types, collections.Hashable)) ReduceAxes = tc.Optional(tc.Union(ReduceAxis, tc.Collection(ReduceAxis))) # pylint: enable=invalid-name @tc.returns(core.LabeledTensor) @tc.accepts(core.LabeledTensorLike, core.LabeledTensorLike, tc.Optional(string_types)) def matmul(a, b, name=None): """Matrix multiply two tensors with rank 1 or 2. If both tensors have rank 2, a matrix-matrix product is performed. If one tensor has rank 1 and the other has rank 2, then a matrix-vector product is performed. If both tensors have rank 1, then a vector dot-product is performed. (This behavior matches that of `numpy.dot`.)
else: axes.append(axis) if squeeze_dimensions: squeeze_op = array_ops.squeeze(labeled_tensor.tensor, squeeze_dimensions, name=scope) else: squeeze_op = array_ops.identity(labeled_tensor.tensor, name=scope) return core.LabeledTensor(squeeze_op, axes) # pylint: disable=invalid-name ReduceAxis = tc.Union(string_types, tc.Tuple(string_types, collections_abc.Hashable)) ReduceAxes = tc.Optional(tc.Union(ReduceAxis, tc.Collection(ReduceAxis))) # pylint: enable=invalid-name @tc.returns(core.LabeledTensor) @tc.accepts(core.LabeledTensorLike, core.LabeledTensorLike, tc.Optional(string_types)) def matmul(a, b, name=None): """Matrix multiply two tensors with rank 1 or 2. If both tensors have rank 2, a matrix-matrix product is performed. If one tensor has rank 1 and the other has rank 2, then a matrix-vector product is performed. If both tensors have rank 1, then a vector dot-product is performed. (This behavior matches that of `numpy.dot`.)