From 8e91907214a06f2d3ef2d40e849a1280dee74af0 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Wed, 7 Oct 2026 06:39:00 -0700 Subject: [PATCH] Replace `# pytype: disable` suppressions with `# pyrefly: ignore` PiperOrigin-RevId: 995072436 --- .../geometry/convolution/graph_convolution.py | 4 ++-- .../geometry/convolution/graph_pooling.py | 6 ++--- .../geometry/convolution/utils.py | 10 ++++----- .../geometry/representation/grid.py | 2 +- .../geometry/representation/point.py | 4 ++-- .../geometry/representation/ray.py | 10 ++++----- .../geometry/representation/triangle.py | 4 ++-- tensorflow_graphics/image/matting.py | 10 ++++----- tensorflow_graphics/image/pyramid.py | 8 +++---- tensorflow_graphics/image/transformer.py | 4 ++-- .../math/interpolation/bspline.py | 22 +++++++++---------- .../math/interpolation/slerp.py | 6 ++--- .../math/interpolation/trilinear.py | 2 +- .../math/interpolation/weighted.py | 4 ++-- tensorflow_graphics/nn/metric/fscore.py | 2 +- .../nn/metric/intersection_over_union.py | 2 +- tensorflow_graphics/nn/metric/precision.py | 2 +- tensorflow_graphics/nn/metric/recall.py | 2 +- .../rendering/camera/orthographic.py | 6 ++--- .../rendering/camera/perspective.py | 18 +++++++-------- .../camera/quadratic_radial_distortion.py | 4 ++-- .../rendering/reflectance/blinn_phong.py | 2 +- .../rendering/reflectance/lambertian.py | 2 +- .../rendering/reflectance/phong.py | 2 +- tensorflow_graphics/util/asserts.py | 16 +++++++------- tensorflow_graphics/util/safe_ops.py | 16 +++++++------- 26 files changed, 85 insertions(+), 85 deletions(-) diff --git a/tensorflow_graphics/geometry/convolution/graph_convolution.py b/tensorflow_graphics/geometry/convolution/graph_convolution.py index e54203884..720499549 100644 --- a/tensorflow_graphics/geometry/convolution/graph_convolution.py +++ b/tensorflow_graphics/geometry/convolution/graph_convolution.py @@ -96,7 +96,7 @@ def feature_steered_convolution( ValueError: if the input dimensions are invalid. """ # pyformat: enable - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): data = tf.convert_to_tensor(value=data) neighbors = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=neighbors) if sizes is not None: @@ -239,7 +239,7 @@ def edge_convolution_template( ValueError: if the input dimensions are invalid. """ # pyformat: enable - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): data = tf.convert_to_tensor(value=data) neighbors = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=neighbors) if sizes is not None: diff --git a/tensorflow_graphics/geometry/convolution/graph_pooling.py b/tensorflow_graphics/geometry/convolution/graph_pooling.py index ace3dab23..d93a6f1d3 100644 --- a/tensorflow_graphics/geometry/convolution/graph_pooling.py +++ b/tensorflow_graphics/geometry/convolution/graph_pooling.py @@ -74,7 +74,7 @@ def pool(data: type_alias.TensorLike, ValueError: if `algorithm` is invalid. """ # pyformat: enable - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): data = tf.convert_to_tensor(value=data) pool_map = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=pool_map) if sizes is not None: @@ -161,7 +161,7 @@ def unpool(data: type_alias.TensorLike, ValueError: if the input dimensions are invalid. """ # pyformat: enable - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): data = tf.convert_to_tensor(value=data) pool_map = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=pool_map) if sizes is not None: @@ -253,7 +253,7 @@ def upsample_transposed_convolution( ValueError: if the input dimensions are invalid. """ # pyformat: enable - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): data = tf.convert_to_tensor(value=data) pool_map = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=pool_map) if sizes is not None: diff --git a/tensorflow_graphics/geometry/convolution/utils.py b/tensorflow_graphics/geometry/convolution/utils.py index 88616b194..25ec9f233 100644 --- a/tensorflow_graphics/geometry/convolution/utils.py +++ b/tensorflow_graphics/geometry/convolution/utils.py @@ -249,7 +249,7 @@ def flatten_batch_to_2d(data: type_alias.TensorLike, Raises: ValueError: if the input tensor dimensions are invalid. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): data = tf.convert_to_tensor(value=data) if sizes is not None: sizes = tf.convert_to_tensor(value=sizes) @@ -272,7 +272,7 @@ def flatten_batch_to_2d(data: type_alias.TensorLike, def unflatten(flat, name="utils_unflatten"): """Invert flatten_batch_to_2d.""" - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): flat = tf.convert_to_tensor(value=flat) output_shape = tf.concat((data_shape[:-1], tf.shape(input=flat)[-1:]), axis=0) @@ -288,7 +288,7 @@ def unflatten(flat, name="utils_unflatten"): def unflatten(flat, name="utils_unflatten"): """Invert flatten_batch_to_2d.""" - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): flat = tf.convert_to_tensor(value=flat) output_shape = tf.concat((data_shape[:-1], tf.shape(input=flat)[-1:]), axis=0) @@ -362,7 +362,7 @@ def unflatten_2d_to_batch(data: type_alias.TensorLike, Returns: A tensor with shape `[A1, A2, ..., max_rows, D2]`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): data = tf.convert_to_tensor(value=data) sizes = tf.convert_to_tensor(value=sizes) if max_rows is None: @@ -418,7 +418,7 @@ def convert_to_block_diag_2d(data: tf.sparse.SparseTensor, TypeError: if the input types are invalid. ValueError: if the input dimensions are invalid. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): data = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=data) if sizes is not None: sizes = tf.convert_to_tensor(value=sizes) diff --git a/tensorflow_graphics/geometry/representation/grid.py b/tensorflow_graphics/geometry/representation/grid.py index 9d6676724..182e2ed33 100644 --- a/tensorflow_graphics/geometry/representation/grid.py +++ b/tensorflow_graphics/geometry/representation/grid.py @@ -98,7 +98,7 @@ def generate(starts, stops, nums, name="grid_generate"): axis and from -2.0 to 2.0 with 5 subdivisions for the y axis. This lead to a tensor of shape (3, 5, 2). """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): starts = tf.convert_to_tensor(value=starts) stops = tf.convert_to_tensor(value=stops) nums = tf.convert_to_tensor(value=nums) diff --git a/tensorflow_graphics/geometry/representation/point.py b/tensorflow_graphics/geometry/representation/point.py index ad561b799..9fca99824 100644 --- a/tensorflow_graphics/geometry/representation/point.py +++ b/tensorflow_graphics/geometry/representation/point.py @@ -55,7 +55,7 @@ def distance_to_ray(point: type_alias.TensorLike, ValueError: If the shape of `point`, `origin`, or 'direction' is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point = tf.convert_to_tensor(value=point) origin = tf.convert_to_tensor(value=origin) direction = tf.convert_to_tensor(value=direction) @@ -99,7 +99,7 @@ def project_to_ray(point: type_alias.TensorLike, ValueError: If the shape of `point`, `origin`, or 'direction' is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point = tf.convert_to_tensor(value=point) origin = tf.convert_to_tensor(value=origin) direction = tf.convert_to_tensor(value=direction) diff --git a/tensorflow_graphics/geometry/representation/ray.py b/tensorflow_graphics/geometry/representation/ray.py index bf9dd04e9..0a9cfb182 100644 --- a/tensorflow_graphics/geometry/representation/ray.py +++ b/tensorflow_graphics/geometry/representation/ray.py @@ -92,7 +92,7 @@ def sample_1d( A tensor of shape `[A1, ..., An, M, 3]` indicating the M points on the ray and a tensor of shape `[A1, ..., An, M]` for the Z values on the points. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): ray_org = tf.convert_to_tensor(ray_org) ray_dir = tf.convert_to_tensor(ray_dir) near = tf.convert_to_tensor(near) * tf.ones((1,)) @@ -175,7 +175,7 @@ def sample_stratified_1d( A tensor of shape `[A1, ..., An, M, 3]` indicating the M points on the ray and a tensor of shape `[A1, ..., An, M]` for the Z values on the points. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): ray_org = tf.convert_to_tensor(ray_org) ray_dir = tf.convert_to_tensor(ray_dir) near = tf.convert_to_tensor(near) * tf.ones((1,)) @@ -245,7 +245,7 @@ def sample_inverse_transform_stratified_1d( A tensor of shape `[A1, ..., An, M, 3]` indicating the M points on the ray and a tensor of shape `[A1, ..., An, M]` for the Z values on the points. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): shape.check_static( tensor=ray_org, tensor_name="ray_org", @@ -312,7 +312,7 @@ def triangulate(startpoints, endpoints, weights, name="ray_triangulate"): Raises: ValueError: If the shape of the arguments is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): startpoints = tf.convert_to_tensor(value=startpoints) endpoints = tf.convert_to_tensor(value=endpoints) weights = tf.convert_to_tensor(value=weights) @@ -403,7 +403,7 @@ def intersection_ray_sphere(sphere_center, `point_on_ray` is not supported. tf.errors.InvalidArgumentError: If `ray` is not normalized. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): sphere_center = tf.convert_to_tensor(value=sphere_center) sphere_radius = tf.convert_to_tensor(value=sphere_radius) ray = tf.convert_to_tensor(value=ray) diff --git a/tensorflow_graphics/geometry/representation/triangle.py b/tensorflow_graphics/geometry/representation/triangle.py index 27a732166..0c6dda5b3 100644 --- a/tensorflow_graphics/geometry/representation/triangle.py +++ b/tensorflow_graphics/geometry/representation/triangle.py @@ -57,7 +57,7 @@ def normal(v0: type_alias.TensorLike, Raises: ValueError: If the shape of `v0`, `v1`, or `v2` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): v0 = tf.convert_to_tensor(value=v0) v1 = tf.convert_to_tensor(value=v1) v2 = tf.convert_to_tensor(value=v2) @@ -104,7 +104,7 @@ def area(v0: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 1]`, where the last dimension represents a normalized vector. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): v0 = tf.convert_to_tensor(value=v0) v1 = tf.convert_to_tensor(value=v1) v2 = tf.convert_to_tensor(value=v2) diff --git a/tensorflow_graphics/image/matting.py b/tensorflow_graphics/image/matting.py index 0d98cda0f..1554b7cd9 100644 --- a/tensorflow_graphics/image/matting.py +++ b/tensorflow_graphics/image/matting.py @@ -131,7 +131,7 @@ def build_matrices(image: type_alias.TensorLike, Raises: ValueError: If `image` is not of rank 4. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): image = tf.convert_to_tensor(value=image) eps = tf.constant(value=eps, dtype=image.dtype) @@ -192,7 +192,7 @@ def linear_coefficients(matte: type_alias.TensorLike, of rank 4. If `pseudo_inverse` is not of rank 5. If `B` is different between `matte` and `pseudo_inverse`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matte = tf.convert_to_tensor(value=matte) pseudo_inverse = tf.convert_to_tensor(value=pseudo_inverse) @@ -216,7 +216,7 @@ def linear_coefficients(matte: type_alias.TensorLike, width = tf.shape(input=matte)[2] + size - 1 coeffs = tf.image.resize_with_crop_or_pad(coeffs, height, width) ones = tf.image.resize_with_crop_or_pad(ones, height, width) - coeffs = _image_average(coeffs, size) / _image_average(ones, size) # pyrefly: ignore[unsupported-operation] + coeffs = _image_average(coeffs, size) / _image_average(ones, size) return tf.split(coeffs, (-1, 1), axis=-1) @@ -246,7 +246,7 @@ def loss(matte: type_alias.TensorLike, same size. If `laplacian` is not of rank 5. If `B` is different between `matte` and `laplacian`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matte = tf.convert_to_tensor(value=matte) laplacian = tf.convert_to_tensor(value=laplacian) @@ -287,7 +287,7 @@ def reconstruct(image: type_alias.TensorLike, the last dimension of `coeff_add` is not 1. If the batch dimensions of `image`, `coeff_mul`, and `coeff_add` do not match. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): image = tf.convert_to_tensor(value=image) coeff_mul = tf.convert_to_tensor(value=coeff_mul) coeff_add = tf.convert_to_tensor(value=coeff_add) diff --git a/tensorflow_graphics/image/pyramid.py b/tensorflow_graphics/image/pyramid.py index cffc4da22..f596425ee 100644 --- a/tensorflow_graphics/image/pyramid.py +++ b/tensorflow_graphics/image/pyramid.py @@ -170,7 +170,7 @@ def downsample(image: type_alias.TensorLike, Raises: ValueError: If the shape of `image` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): image = tf.convert_to_tensor(value=image) shape.check_static(tensor=image, tensor_name="image", has_rank=4) @@ -196,7 +196,7 @@ def merge(levels: List[type_alias.TensorLike], Raises: ValueError: If the shape of the elements of `levels` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): levels = [tf.convert_to_tensor(value=level) for level in levels] for index, level in enumerate(levels): @@ -229,7 +229,7 @@ def split(image: type_alias.TensorLike, Raises: ValueError: If the shape of `image` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): image = tf.convert_to_tensor(value=image) shape.check_static(tensor=image, tensor_name="image", has_rank=4) @@ -264,7 +264,7 @@ def upsample(image: type_alias.TensorLike, Raises: ValueError: If the shape of `image` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): image = tf.convert_to_tensor(value=image) shape.check_static(tensor=image, tensor_name="image", has_rank=4) diff --git a/tensorflow_graphics/image/transformer.py b/tensorflow_graphics/image/transformer.py index d27f994a7..ff3ac5bc9 100644 --- a/tensorflow_graphics/image/transformer.py +++ b/tensorflow_graphics/image/transformer.py @@ -77,7 +77,7 @@ def sample(image: type_alias.TensorLike, ValueError: If `image` has rank != 4. If `warp` has rank < 2 or its last dimension is not 2. If `image` and `warp` batch dimension does not match. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): image = tf.convert_to_tensor(value=image, name="image") warp = tf.convert_to_tensor(value=warp, name="warp") @@ -154,7 +154,7 @@ def perspective_transform( its last two dimensions are not 3. If `image` and `transform_matrix` batch dimension does not match. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): image = tf.convert_to_tensor(value=image, name="image") transform_matrix = tf.convert_to_tensor( value=transform_matrix, name="transform_matrix") diff --git a/tensorflow_graphics/math/interpolation/bspline.py b/tensorflow_graphics/math/interpolation/bspline.py index 3fe6c4088..1c7efac3a 100644 --- a/tensorflow_graphics/math/interpolation/bspline.py +++ b/tensorflow_graphics/math/interpolation/bspline.py @@ -44,13 +44,13 @@ class Degree(enum.IntEnum): def _constant(position: tf.Tensor) -> tf.Tensor: """B-Spline basis function of degree 0 for positions in the range [0, 1].""" # A piecewise constant spline is discontinuous at the knots. - return tf.expand_dims(tf.clip_by_value(1.0 + position, 1.0, 1.0), axis=-1) # pyrefly: ignore[unsupported-operation] + return tf.expand_dims(tf.clip_by_value(1.0 + position, 1.0, 1.0), axis=-1) def _linear(position: tf.Tensor) -> tf.Tensor: """B-Spline basis functions of degree 1 for positions in the range [0, 1].""" # Piecewise linear splines are C0 smooth. - return tf.stack((1.0 - position, position), axis=-1) # pyrefly: ignore[unsupported-operation] + return tf.stack((1.0 - position, position), axis=-1) def _quadratic(position: tf.Tensor) -> tf.Tensor: @@ -59,7 +59,7 @@ def _quadratic(position: tf.Tensor) -> tf.Tensor: pos_sq = tf.pow(position, 2.0) # Piecewise quadratic splines are C1 smooth. - return tf.stack((tf.pow(1.0 - position, 2.0) / 2.0, -pos_sq + position + 0.5, # pyrefly: ignore[unsupported-operation] + return tf.stack((tf.pow(1.0 - position, 2.0) / 2.0, -pos_sq + position + 0.5, pos_sq / 2.0), axis=-1) @@ -67,14 +67,14 @@ def _quadratic(position: tf.Tensor) -> tf.Tensor: def _cubic(position: tf.Tensor) -> tf.Tensor: """B-Spline basis functions of degree 3 for positions in the range [0, 1].""" # We pre-calculate the terms that are used multiple times. - neg_pos = 1.0 - position # pyrefly: ignore[unsupported-operation] + neg_pos = 1.0 - position pos_sq = tf.pow(position, 2.0) pos_cb = tf.pow(position, 3.0) # Piecewise cubic splines are C2 smooth. return tf.stack( (tf.pow(neg_pos, 3.0) / 6.0, (3.0 * pos_cb - 6.0 * pos_sq + 4.0) / 6.0, - (-3.0 * pos_cb + 3.0 * pos_sq + 3.0 * position + 1.0) / 6.0, # pyrefly: ignore[unsupported-operation] + (-3.0 * pos_cb + 3.0 * pos_sq + 3.0 * position + 1.0) / 6.0, pos_cb / 6.0), axis=-1) @@ -82,7 +82,7 @@ def _cubic(position: tf.Tensor) -> tf.Tensor: def _quartic(position: tf.Tensor) -> tf.Tensor: """B-Spline basis functions of degree 4 for positions in the range [0, 1].""" # We pre-calculate the terms that are used multiple times. - neg_pos = 1.0 - position # pyrefly: ignore[unsupported-operation] + neg_pos = 1.0 - position pos_sq = tf.pow(position, 2.0) pos_cb = tf.pow(position, 3.0) pos_qt = tf.pow(position, 4.0) @@ -92,8 +92,8 @@ def _quartic(position: tf.Tensor) -> tf.Tensor: (tf.pow(neg_pos, 4.0) / 24.0, (-4.0 * tf.pow(neg_pos, 4.0) + 4.0 * tf.pow(neg_pos, 3.0) + 6.0 * tf.pow(neg_pos, 2.0) + 4.0 * neg_pos + 1.0) / 24.0, - (pos_qt - 2.0 * pos_cb - pos_sq + 2.0 * position) / 4.0 + 11.0 / 24.0, # pyrefly: ignore[unsupported-operation] - (-4.0 * pos_qt + 4.0 * pos_cb + 6.0 * pos_sq + 4.0 * position + 1.0) / # pyrefly: ignore[unsupported-operation] + (pos_qt - 2.0 * pos_cb - pos_sq + 2.0 * position) / 4.0 + 11.0 / 24.0, + (-4.0 * pos_qt + 4.0 * pos_cb + 6.0 * pos_sq + 4.0 * position + 1.0) / 24.0, pos_qt / 24.0), axis=-1) @@ -137,7 +137,7 @@ def knot_weights( ValueError: If degree is greater than 4 or num_knots - 1, or less than 0. InvalidArgumentError: If positions are not in the right range. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): positions = tf.convert_to_tensor(value=positions) if degree > 4 or degree < 0: @@ -236,7 +236,7 @@ def interpolate_with_weights( Raises: ValueError: If the last dimension of knots and weights is not equal. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): knots = tf.convert_to_tensor(value=knots) weights = tf.convert_to_tensor(value=weights) @@ -271,7 +271,7 @@ def interpolate(knots: type_alias.TensorLike, A tensor of shape `[A1, ... An, B1, ..., Bk]`, which is the result of spline interpolation. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): knots = tf.convert_to_tensor(value=knots) positions = tf.convert_to_tensor(value=positions) diff --git a/tensorflow_graphics/math/interpolation/slerp.py b/tensorflow_graphics/math/interpolation/slerp.py index b333532cd..9fd20091c 100644 --- a/tensorflow_graphics/math/interpolation/slerp.py +++ b/tensorflow_graphics/math/interpolation/slerp.py @@ -142,7 +142,7 @@ def interpolate_with_weights( A tensor of shape `[A1, ... , An, M]` containing the result of the interpolation. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): return weight1 * vector1 + weight2 * vector2 @@ -185,7 +185,7 @@ def quaternion_weights( Two tensors of shape `[A1, ... , An, 1]` each, which are the two slerp weights for each quaternion. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion1 = tf.convert_to_tensor(value=quaternion1) quaternion2 = tf.convert_to_tensor(value=quaternion2) percent = tf.convert_to_tensor(value=percent, dtype=quaternion1.dtype) @@ -253,7 +253,7 @@ def vector_weights(vector1: type_alias.TensorLike, Two tensors of shape `[A1, ... , An, 1]`, representing interpolation weights for each input vector. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector1 = tf.convert_to_tensor(value=vector1) vector2 = tf.convert_to_tensor(value=vector2) percent = tf.convert_to_tensor(value=percent, dtype=vector1.dtype) diff --git a/tensorflow_graphics/math/interpolation/trilinear.py b/tensorflow_graphics/math/interpolation/trilinear.py index d577aab10..35230aa9a 100644 --- a/tensorflow_graphics/math/interpolation/trilinear.py +++ b/tensorflow_graphics/math/interpolation/trilinear.py @@ -41,7 +41,7 @@ def interpolate(grid_3d: type_alias.TensorLike, A tensor of shape `[A1, ..., An, M, C]` """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): grid_3d = tf.convert_to_tensor(value=grid_3d) sampling_points = tf.convert_to_tensor(value=sampling_points) diff --git a/tensorflow_graphics/math/interpolation/weighted.py b/tensorflow_graphics/math/interpolation/weighted.py index 86d0c53eb..3f1151341 100644 --- a/tensorflow_graphics/math/interpolation/weighted.py +++ b/tensorflow_graphics/math/interpolation/weighted.py @@ -61,7 +61,7 @@ def interpolate(points: type_alias.TensorLike, A tensor of shape `[A1, ..., An, M]` storing the interpolated M-D points. The first n dimensions will be the same as weights and indices. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): points = tf.convert_to_tensor(value=points) weights = tf.convert_to_tensor(value=weights) indices = tf.convert_to_tensor(value=indices) @@ -128,7 +128,7 @@ def get_barycentric_coordinates( valid: A boolean tensor of shape `[A1, ..., An, N], which is `True` where pixels are inside the triangle, and `False` otherwise. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): triangle_vertices = tf.convert_to_tensor(value=triangle_vertices) pixels = tf.convert_to_tensor(value=pixels) diff --git a/tensorflow_graphics/nn/metric/fscore.py b/tensorflow_graphics/nn/metric/fscore.py index 31396da24..8bb696c39 100644 --- a/tensorflow_graphics/nn/metric/fscore.py +++ b/tensorflow_graphics/nn/metric/fscore.py @@ -66,7 +66,7 @@ def evaluate(ground_truth: type_alias.TensorLike, ValueError: if the shape of `ground_truth`, `prediction` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): ground_truth = tf.convert_to_tensor(value=ground_truth) prediction = tf.convert_to_tensor(value=prediction) diff --git a/tensorflow_graphics/nn/metric/intersection_over_union.py b/tensorflow_graphics/nn/metric/intersection_over_union.py index 8daa9b550..bbfbca76d 100644 --- a/tensorflow_graphics/nn/metric/intersection_over_union.py +++ b/tensorflow_graphics/nn/metric/intersection_over_union.py @@ -54,7 +54,7 @@ def evaluate(ground_truth_labels: type_alias.TensorLike, ValueError: if the shape of `ground_truth_labels`, `predicted_labels` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): ground_truth_labels = tf.convert_to_tensor(value=ground_truth_labels) predicted_labels = tf.convert_to_tensor(value=predicted_labels) diff --git a/tensorflow_graphics/nn/metric/precision.py b/tensorflow_graphics/nn/metric/precision.py index 58a2c6ff5..814a82fb1 100644 --- a/tensorflow_graphics/nn/metric/precision.py +++ b/tensorflow_graphics/nn/metric/precision.py @@ -66,7 +66,7 @@ class and return a single precision value. Defaults to true. Raises: ValueError: if the shape of `ground_truth`, `prediction` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): ground_truth = tf.cast( x=tf.convert_to_tensor(value=ground_truth), dtype=tf.int32) prediction = tf.convert_to_tensor(value=prediction) diff --git a/tensorflow_graphics/nn/metric/recall.py b/tensorflow_graphics/nn/metric/recall.py index e068d0f5a..7e82be870 100644 --- a/tensorflow_graphics/nn/metric/recall.py +++ b/tensorflow_graphics/nn/metric/recall.py @@ -66,7 +66,7 @@ class and return a single recall value. Defaults to true. Raises: ValueError: if the shape of `ground_truth`, `prediction` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): ground_truth = tf.cast( x=tf.convert_to_tensor(value=ground_truth), dtype=tf.int32) prediction = tf.convert_to_tensor(value=prediction) diff --git a/tensorflow_graphics/rendering/camera/orthographic.py b/tensorflow_graphics/rendering/camera/orthographic.py index 05d17159f..44f6ab0a0 100644 --- a/tensorflow_graphics/rendering/camera/orthographic.py +++ b/tensorflow_graphics/rendering/camera/orthographic.py @@ -59,7 +59,7 @@ def project(point_3d: type_alias.TensorLike, Raises: ValueError: If the shape of `point_3d` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_3d = tf.convert_to_tensor(value=point_3d) shape.check_static( @@ -97,7 +97,7 @@ def ray(point_2d: type_alias.TensorLike, Raises: ValueError: If the shape of `point_2d` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_2d = tf.convert_to_tensor(value=point_2d) shape.check_static( @@ -139,7 +139,7 @@ def unproject(point_2d: type_alias.TensorLike, Raises: ValueError: If the shape of `point_2d`, `depth` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_2d = tf.convert_to_tensor(value=point_2d) depth = tf.convert_to_tensor(value=depth) diff --git a/tensorflow_graphics/rendering/camera/perspective.py b/tensorflow_graphics/rendering/camera/perspective.py index e7368beb7..0efc0648f 100644 --- a/tensorflow_graphics/rendering/camera/perspective.py +++ b/tensorflow_graphics/rendering/camera/perspective.py @@ -82,7 +82,7 @@ def parameters_from_right_handed( represent the near and far clipping planes used to construct `projection_matrix`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): projection_matrix = tf.convert_to_tensor(value=projection_matrix) shape.check_static( @@ -141,7 +141,7 @@ def right_handed(vertical_field_of_view: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 4, 4]`, containing matrices of right handed perspective-view frustum. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vertical_field_of_view = tf.convert_to_tensor(value=vertical_field_of_view) aspect_ratio = tf.convert_to_tensor(value=aspect_ratio) near = tf.convert_to_tensor(value=near) @@ -220,7 +220,7 @@ def intrinsics_from_matrix( Raises: ValueError: If the shape of `matrix` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -281,7 +281,7 @@ def matrix_from_intrinsics( ValueError: If the shape of `focal`, or `principal_point` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) skew = tf.convert_to_tensor(value=skew) @@ -363,7 +363,7 @@ def project(point_3d: type_alias.TensorLike, ValueError: If the shape of `point_3d`, `focal`, or `principal_point` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_3d = tf.convert_to_tensor(value=point_3d) focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) @@ -427,7 +427,7 @@ def ray(point_2d: type_alias.TensorLike, ValueError: If the shape of `point_2d`, `focal`, or `principal_point` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_2d = tf.convert_to_tensor(value=point_2d) focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) @@ -478,7 +478,7 @@ def random_rays(focal: tf.Tensor, A tensor of shape `[A1, ..., An, M, 3]` with the ray directions and a tensor of shape `[A1, ..., An, M, 2]` with the pixel x, y locations. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) @@ -531,7 +531,7 @@ def random_patches(focal: tf.Tensor, ray directions in 3D passing from the M*N pixels of the patch and a tensor of shape `[A1, ..., An, M*N, 2]` with the pixel x, y locations. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) @@ -619,7 +619,7 @@ def unproject(point_2d: type_alias.TensorLike, ValueError: If the shape of `point_2d`, `depth`, `focal`, or `principal_point` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_2d = tf.convert_to_tensor(value=point_2d) depth = tf.convert_to_tensor(value=depth) focal = tf.convert_to_tensor(value=focal) diff --git a/tensorflow_graphics/rendering/camera/quadratic_radial_distortion.py b/tensorflow_graphics/rendering/camera/quadratic_radial_distortion.py index 9d3e9900e..fea19fce9 100644 --- a/tensorflow_graphics/rendering/camera/quadratic_radial_distortion.py +++ b/tensorflow_graphics/rendering/camera/quadratic_radial_distortion.py @@ -79,7 +79,7 @@ def distortion_factor( monotonically increasing. Wherever `overflow_mask` is True, `distortion_factor`'s value is meaningless. """ - with tf.name_scope(name,): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name,): squared_radius = tf.convert_to_tensor(value=squared_radius) distortion_coefficient = tf.convert_to_tensor(value=distortion_coefficient) @@ -154,7 +154,7 @@ def undistortion_factor( `undistortion_factor`'s value is meaningless. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): distorted_squared_radius = tf.convert_to_tensor( value=distorted_squared_radius) distortion_coefficient = tf.convert_to_tensor(value=distortion_coefficient) diff --git a/tensorflow_graphics/rendering/reflectance/blinn_phong.py b/tensorflow_graphics/rendering/reflectance/blinn_phong.py index e013418fc..ec5f75012 100644 --- a/tensorflow_graphics/rendering/reflectance/blinn_phong.py +++ b/tensorflow_graphics/rendering/reflectance/blinn_phong.py @@ -89,7 +89,7 @@ def brdf(direction_incoming_light: type_alias.TensorLike, InvalidArgumentError: if not all of shininess values are non-negative, or if at least one element of `albedo` is outside of [0,1]. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): direction_incoming_light = tf.convert_to_tensor( value=direction_incoming_light) direction_outgoing_light = tf.convert_to_tensor( diff --git a/tensorflow_graphics/rendering/reflectance/lambertian.py b/tensorflow_graphics/rendering/reflectance/lambertian.py index c2046f4ed..4b38c86b7 100644 --- a/tensorflow_graphics/rendering/reflectance/lambertian.py +++ b/tensorflow_graphics/rendering/reflectance/lambertian.py @@ -65,7 +65,7 @@ def brdf(direction_incoming_light: type_alias.TensorLike, InvalidArgumentError: if at least one element of `albedo` is outside of [0,1]. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): direction_incoming_light = tf.convert_to_tensor( value=direction_incoming_light) direction_outgoing_light = tf.convert_to_tensor( diff --git a/tensorflow_graphics/rendering/reflectance/phong.py b/tensorflow_graphics/rendering/reflectance/phong.py index cd66269db..a0a584c86 100644 --- a/tensorflow_graphics/rendering/reflectance/phong.py +++ b/tensorflow_graphics/rendering/reflectance/phong.py @@ -85,7 +85,7 @@ def brdf(direction_incoming_light: type_alias.TensorLike, InvalidArgumentError: if not all of shininess values are non-negative, or if at least one element of `albedo` is outside of [0,1]. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): direction_incoming_light = tf.convert_to_tensor( value=direction_incoming_light) direction_outgoing_light = tf.convert_to_tensor( diff --git a/tensorflow_graphics/util/asserts.py b/tensorflow_graphics/util/asserts.py index 862dc6696..874cd5dc9 100644 --- a/tensorflow_graphics/util/asserts.py +++ b/tensorflow_graphics/util/asserts.py @@ -51,7 +51,7 @@ def assert_no_infs_or_nans( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return tensor - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): tensor = tf.convert_to_tensor(value=tensor) assert_ops = (tf.debugging.check_numerics( @@ -87,7 +87,7 @@ def assert_all_above( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector = tf.convert_to_tensor(value=vector) minval = tf.convert_to_tensor(value=minval, dtype=vector.dtype) @@ -126,7 +126,7 @@ def assert_all_below( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector = tf.convert_to_tensor(value=vector) maxval = tf.convert_to_tensor(value=maxval, dtype=vector.dtype) @@ -172,7 +172,7 @@ def assert_all_in_range( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector = tf.convert_to_tensor(value=vector) minval = tf.convert_to_tensor(value=minval, dtype=vector.dtype) maxval = tf.convert_to_tensor(value=maxval, dtype=vector.dtype) @@ -218,7 +218,7 @@ def assert_nonzero_norm( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector = tf.convert_to_tensor(value=vector) if eps is None: eps = select_eps_for_division(vector.dtype) @@ -258,7 +258,7 @@ def assert_normalized( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector = tf.convert_to_tensor(value=vector) if eps is None: eps = select_eps_for_division(vector.dtype) @@ -298,7 +298,7 @@ def assert_at_least_k_non_zero_entries( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return tensor - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): tensor = tf.convert_to_tensor(value=tensor) indicator = tf.cast(tf.math.greater(tensor, 0.0), dtype=tensor.dtype) @@ -329,7 +329,7 @@ def assert_binary( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return tensor - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): tensor = tf.convert_to_tensor(value=tensor) condition = tf.reduce_all( input_tensor=tf.logical_or(tf.equal(tensor, 0), tf.equal(tensor, 1))) diff --git a/tensorflow_graphics/util/safe_ops.py b/tensorflow_graphics/util/safe_ops.py index 7c2ce7b9c..7a174d265 100644 --- a/tensorflow_graphics/util/safe_ops.py +++ b/tensorflow_graphics/util/safe_ops.py @@ -38,7 +38,7 @@ def nonzero_sign( x: type_alias.TensorLike, name: str = 'nonzero_sign') -> tf.Tensor: """Returns the sign of x with sign(0) defined as 1 instead of 0.""" - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): x = tf.convert_to_tensor(value=x) one = tf.ones_like(x) @@ -76,7 +76,7 @@ def safe_cospx_div_cosx( Returns: A tensor of shape `[A1, ..., An]` containing the resulting values. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): theta = tf.convert_to_tensor(value=theta) factor = tf.convert_to_tensor(value=factor, dtype=theta.dtype) if eps is None: @@ -88,7 +88,7 @@ def safe_cospx_div_cosx( # factors as small as 1e-10 correctly, while preventing a division by zero. eps *= tf.clip_by_value(1.0 / factor, 1.0, 1e10) sign = nonzero_sign(0.5 * np.pi - (theta - 0.5 * np.pi) % np.pi) - theta += sign * eps # pyrefly: ignore[unsupported-operation] + theta += sign * eps div = tf.cos(factor * theta) / tf.cos(theta) return asserts.assert_no_infs_or_nans(div) @@ -138,7 +138,7 @@ def safe_shrink( Returns: A tensor of shape `[A1, ..., An]` containing the shrinked values. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector = tf.convert_to_tensor(value=vector) if eps is None: eps = asserts.select_eps_for_addition(vector.dtype) @@ -181,7 +181,7 @@ def safe_signed_div( Returns: A tensor of shape `[A1, ..., An]` containing the results of division. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): a = tf.convert_to_tensor(value=a) b = tf.convert_to_tensor(value=b) if eps is None: @@ -222,7 +222,7 @@ def safe_sinpx_div_sinx( Returns: A tensor of shape `[A1, ..., An]` containing the resulting values. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): theta = tf.convert_to_tensor(value=theta) factor = tf.convert_to_tensor(value=factor, dtype=theta.dtype) if eps is None: @@ -234,7 +234,7 @@ def safe_sinpx_div_sinx( # factors as small as 1e-10 correctly, while preventing a division by zero. eps *= tf.clip_by_value(1.0 / factor, 1.0, 1e10) sign = nonzero_sign(0.5 * np.pi - theta % np.pi) - theta += sign * eps # pyrefly: ignore[unsupported-operation] + theta += sign * eps div = tf.sin(factor * theta) / tf.sin(theta) return asserts.assert_no_infs_or_nans(div) @@ -264,7 +264,7 @@ def safe_unsigned_div( Returns: A tensor of shape `[A1, ..., An]` containing the results of division. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): a = tf.convert_to_tensor(value=a) b = tf.convert_to_tensor(value=b) if eps is None: