From 6449c7058fda3912f9e8b011d9d1818a31e193c3 Mon Sep 17 00:00:00 2001 From: ivy-dev-bot Date: Thu, 19 Sep 2024 04:04:47 +0000 Subject: [PATCH] auto-lint code --- .../backends/jax/experimental/layers.py | 35 +++++++++++-------- ivy/functional/backends/tensorflow/general.py | 4 ++- ivy/functional/ivy/device.py | 1 - ivy/functional/ivy/general.py | 1 + .../hypothesis_helpers/array_helpers.py | 1 + scripts/backend_generation/generate.py | 10 ++---- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/ivy/functional/backends/jax/experimental/layers.py b/ivy/functional/backends/jax/experimental/layers.py index 0b98078cb90f..1eea73998f96 100644 --- a/ivy/functional/backends/jax/experimental/layers.py +++ b/ivy/functional/backends/jax/experimental/layers.py @@ -723,21 +723,28 @@ def interpolate( return ivy.inplace_update(out, ret) return ret -def _check_mode(*args, mode="linear", recompute_scale_factor=None, align_corners=None, **kwargs): + +def _check_mode( + *args, mode="linear", recompute_scale_factor=None, align_corners=None, **kwargs +): return ( - mode not in [ - "area", - "nearest", - "nd", - "tf_area", - "mitchellcubic", - "gaussian", - "bicubic", - ] - and not align_corners - and recompute_scale_factor -) -interpolate.partial_mixed_handler =_check_mode + mode + not in [ + "area", + "nearest", + "nd", + "tf_area", + "mitchellcubic", + "gaussian", + "bicubic", + ] + and not align_corners + and recompute_scale_factor + ) + + +interpolate.partial_mixed_handler = _check_mode + def reduce_window( operand: JaxArray, diff --git a/ivy/functional/backends/tensorflow/general.py b/ivy/functional/backends/tensorflow/general.py index 7f3d5610cc57..8af68737daa6 100644 --- a/ivy/functional/backends/tensorflow/general.py +++ b/ivy/functional/backends/tensorflow/general.py @@ -68,7 +68,9 @@ def get_item( query = tf.cast(query, tf.int64) return tf.gather(x, query, axis=0) else: - if isinstance(query, (list, tuple)) and any([isinstance(q, (list, tuple)) for q in query]): + if isinstance(query, (list, tuple)) and any( + [isinstance(q, (list, tuple)) for q in query] + ): # convert any lists/tuples within the query to slices query = tuple( [slice(*q) if isinstance(q, (list, tuple)) else q for q in query] diff --git a/ivy/functional/ivy/device.py b/ivy/functional/ivy/device.py index 44f710168bf8..158cfe9e1907 100644 --- a/ivy/functional/ivy/device.py +++ b/ivy/functional/ivy/device.py @@ -6,7 +6,6 @@ import abc import math import psutil -import warnings import types from typing import Type, Optional, Tuple diff --git a/ivy/functional/ivy/general.py b/ivy/functional/ivy/general.py index 16737a29410d..dd176f72fe4b 100644 --- a/ivy/functional/ivy/general.py +++ b/ivy/functional/ivy/general.py @@ -21,6 +21,7 @@ ) import einops import numpy as np + try: import ml_dtypes # noqa except: diff --git a/ivy_tests/test_ivy/helpers/hypothesis_helpers/array_helpers.py b/ivy_tests/test_ivy/helpers/hypothesis_helpers/array_helpers.py index 1329796f1251..0d0049194ae9 100644 --- a/ivy_tests/test_ivy/helpers/hypothesis_helpers/array_helpers.py +++ b/ivy_tests/test_ivy/helpers/hypothesis_helpers/array_helpers.py @@ -7,6 +7,7 @@ from operator import mul import sys import string + try: import ml_dtypes # noqa except: diff --git a/scripts/backend_generation/generate.py b/scripts/backend_generation/generate.py index 3112e5696ae6..1faec98d6936 100644 --- a/scripts/backend_generation/generate.py +++ b/scripts/backend_generation/generate.py @@ -161,9 +161,7 @@ def _should_install_backend(package_name): with open("../../requirements/optional.txt", "a") as reqr_file: reqr_file.write("\n" + package_name + "\n") except subprocess.CalledProcessError as e: - raise RuntimeError( - f"Installing {package_name} failed. {e}" - ) from e + raise RuntimeError(f"Installing {package_name} failed. {e}") from e elif ret.lower() == "n": print( "Will continue without backend installed, " @@ -242,11 +240,7 @@ def _add_alias_for_backend(): def _update_flag_config_value(key): # Handle flag input and update it's value - ret = input( - f"\nToggle flag {key} [Y/n]? " - f"default: '{config_flags[key]}'" - f": " - ) + ret = input(f"\nToggle flag {key} [Y/n]? " f"default: '{config_flags[key]}'" f": ") ret = ret.strip(" ").lower() if ret == "y": config_flags[key] = not config_flags[key]