From 72fa1698afd8e262a5c35c0567bbaa8d3873006b Mon Sep 17 00:00:00 2001 From: ivy-dev-bot Date: Sun, 30 Jun 2024 05:57:56 +0000 Subject: [PATCH] auto-lint code --- binaries.json | 2 +- ivy/compiler/compiler.py | 17 ++++++++++------- ivy/functional/frontends/torch/linalg.py | 4 ++-- ivy/functional/ivy/general.py | 10 ++-------- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/binaries.json b/binaries.json index 8fa03137f07a..c9eb6cde7206 100644 --- a/binaries.json +++ b/binaries.json @@ -139,4 +139,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/frontends/torch/linalg.py b/ivy/functional/frontends/torch/linalg.py index 5f37f7fdf0fc..fb762c363a03 100644 --- a/ivy/functional/frontends/torch/linalg.py +++ b/ivy/functional/frontends/torch/linalg.py @@ -21,7 +21,7 @@ def cholesky(input, *, upper=False, out=None): ) def cholesky_ex(input, *, upper=False, check_errors=False, out=None): try: - results = namedtuple("cholesky_ex", ['L', 'info']) + results = namedtuple("cholesky_ex", ["L", "info"]) matrix = ivy.cholesky(input, upper=upper, out=out) info = ivy.zeros(input.shape[:-2], dtype=ivy.int32) return results(matrix, info) @@ -29,7 +29,7 @@ def cholesky_ex(input, *, upper=False, check_errors=False, out=None): if check_errors: raise RuntimeError(e) from e else: - results = namedtuple("cholesky_ex", ['L', 'info']) + results = namedtuple("cholesky_ex", ["L", "info"]) matrix = input * math.nan info = ivy.ones(input.shape[:-2], dtype=ivy.int32) return results(matrix, info) diff --git a/ivy/functional/ivy/general.py b/ivy/functional/ivy/general.py index e59ea2ed5725..d312ecdb72da 100644 --- a/ivy/functional/ivy/general.py +++ b/ivy/functional/ivy/general.py @@ -2879,15 +2879,9 @@ def set_item( ivy.array([[ 0, -1, 20], [10, 10, 10]]) """ - # TODO: we may be able to remove this logic by instead tracing _parse_query as a node in the graph?? - if ( - isinstance(query, (list, tuple)) and - any([ - q is Ellipsis or ( - isinstance(q, slice) and q.stop is None - ) for q in query - ]) + if isinstance(query, (list, tuple)) and any( + [q is Ellipsis or (isinstance(q, slice) and q.stop is None) for q in query] ): # use numpy for item setting when an ellipsis or unbounded slice is present, # as they would otherwise cause static dim sizes to be traced into the graph