From 46df064ab622edd3e221a30621715628b7198999 Mon Sep 17 00:00:00 2001 From: ivy-dev-bot Date: Fri, 26 Jul 2024 04:05:07 +0000 Subject: [PATCH] auto-lint code --- binaries.json | 2 +- ivy/compiler/compiler.py | 17 ++++++++++------- ivy/functional/backends/tensorflow/gradients.py | 8 +++++--- ivy/stateful/module.py | 12 +++++++++++- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/binaries.json b/binaries.json index 011223d7356a..5443c1e3e441 100644 --- a/binaries.json +++ b/binaries.json @@ -143,4 +143,4 @@ } ] } -} \ No newline at end of file +} diff --git a/ivy/compiler/compiler.py b/ivy/compiler/compiler.py index 6390134c580c..fb1ba085e982 100644 --- a/ivy/compiler/compiler.py +++ b/ivy/compiler/compiler.py @@ -16,14 +16,16 @@ def source_to_source( as well e.g. (source="torch_frontend", target="ivy") or (source="torch_frontend", target="tensorflow") etc. Args: + ---- object: The object (class/function) to be translated. source (str, optional): The source framework. Defaults to 'torch'. target (str, optional): The target framework. Defaults to 'torch_frontend'. profiling: Whether to add performance profiling. Returns: - The translated object.""" - + ------- + The translated object. + """ from ._compiler import source_to_source as _source_to_source return _source_to_source( @@ -54,7 +56,8 @@ def trace_graph( params_v=None, v=None ): - """Takes `fn` and traces it into a more efficient composition of backend operations. + """Takes `fn` and traces it into a more efficient composition of backend + operations. Parameters ---------- @@ -124,8 +127,8 @@ def trace_graph( >>> start = time.time() >>> graph(x) >>> print(time.time() - start) - 0.0001785755157470703""" - + 0.0001785755157470703 + """ from ._compiler import trace_graph as _trace_graph return _trace_graph( @@ -189,8 +192,8 @@ def transpile( Returns ------- - Either a transpiled Graph or a non-initialized LazyGraph.""" - + Either a transpiled Graph or a non-initialized LazyGraph. + """ from ._compiler import transpile as _transpile return _transpile( diff --git a/ivy/functional/backends/tensorflow/gradients.py b/ivy/functional/backends/tensorflow/gradients.py index c1e2b848e78c..eb12f8844822 100644 --- a/ivy/functional/backends/tensorflow/gradients.py +++ b/ivy/functional/backends/tensorflow/gradients.py @@ -79,9 +79,11 @@ def execute_with_gradients( # Conversion of KerasVariable to tf.Variable within xs_required container, so they can be watched if ivy.is_ivy_container(xs_required): ivy.nested_map( - lambda x: x._value - if "keras.src.backend.tensorflow.core.Variable" in str(x.__class__) - else x, + lambda x: ( + x._value + if "keras.src.backend.tensorflow.core.Variable" in str(x.__class__) + else x + ), xs_required, include_derived=True, ) diff --git a/ivy/stateful/module.py b/ivy/stateful/module.py index c89e9706ad3d..3758aeaf2c1a 100644 --- a/ivy/stateful/module.py +++ b/ivy/stateful/module.py @@ -783,7 +783,17 @@ def _get_variable_name(variable): self._native_params = ivy.Container( OrderedDict( sorted( - [(param.name if tf.__version__ < "2.16.0" else _get_variable_name(param), param) for param in self._native_module.variables], + [ + ( + ( + param.name + if tf.__version__ < "2.16.0" + else _get_variable_name(param) + ), + param, + ) + for param in self._native_module.variables + ], key=lambda kv: kv[0], ) ),