# Buggy code
def shear_x(image: TensorLike, level: float, replace: int) -> TensorLike:
    """Perform shear operation on an image (x-axis).

    Args:
        image: A 3D image Tensor.
        level: A float denoting shear element along y-axis
        replace: A one or three value 1D tensor to fill empty pixels.
    Returns:
        Transformed image along X or Y axis, with space outside image
        filled with replace.
    """
    # Shear parallel to x axis is a projective transform
    # with a matrix form of:
    # [1  level
    #  0  1].
    image = transform(wrap(image), [1.0, level, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0])
    return unwrap(image, replace)


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-50c68fed8a6d> in <module>()
----> 1 sheared_image3 = tfa.image.shear_x(float_image, 0.3, replace=0.5)
2 sheared_image4 = tfa.image.shear_y(float_image, 0.4, replace=0.4)
3
4 plt.imshow(sheared_image3)
5 plt.show()

5 frames
/usr/local/lib/python3.6/dist-packages/tensorflow_addons/image/transform_ops.py in shear_x(image, level, replace)
324     #  0  1].
325     image = transform(wrap(image), [1.0, level, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0])
--> 326     return unwrap(image, replace)
327
328

/usr/local/lib/python3.6/dist-packages/tensorflow_addons/image/utils.py in unwrap(image, replace)
135     alpha_channel = flattened_image[:, 3]
136
--> 137     replace = tf.constant(replace, tf.uint8)
138     if tf.rank(replace) == 0:
139         replace = tf.expand_dims(replace, 0)

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py in constant(value, dtype, shape, name)
262   """
263   return _constant_impl(value, dtype, shape, name, verify_shape=False,
--> 264                         allow_broadcast=True)
265
266

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast)
273       with trace.Trace("tf.constant"):
274         return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
--> 275     return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
276
277   g = ops.get_default_graph()

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py in _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
298 def _constant_eager_impl(ctx, value, dtype, shape, verify_shape):
299   """Implementation of eager constant."""
--> 300   t = convert_to_eager_tensor(value, ctx, dtype)
301   if shape is None:
302     return t

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py in convert_to_eager_tensor(value, ctx, dtype)
96       dtype = dtypes.as_dtype(dtype).as_datatype_enum
97   ctx.ensure_initialized()
---> 98   return ops.EagerTensor(value, ctx.device_name, dtype)
99
100

TypeError: Cannot convert 0.5 to EagerTensor of dtype uint8

# Fixed code
def shear_x(image: TensorLike, level: float, replace: TensorLike) -> TensorLike:
    """Perform shear operation on an image (x-axis).

    Args:
        image: A 3D image `Tensor`.
        level: A float denoting shear element along y-axis
        replace: A one or three value 1D tensor to fill empty pixels.
    Returns:
        Transformed image along X or Y axis, with space outside image
        filled with replace.
    """
    # Shear parallel to x axis is a projective transform
    # with a matrix form of:
    # [1  level
    #  0  1].
    image = transform(wrap(image), [1.0, level, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0])
    return unwrap(image, replace)