Skip to content

Commit

Permalink
🤖 Lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-branch committed Jan 5, 2024
1 parent 8405f2b commit 207dec0
Show file tree
Hide file tree
Showing 216 changed files with 5,290 additions and 7,240 deletions.
27 changes: 11 additions & 16 deletions ivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,7 @@ def vec_sig_fig(x, sig_fig=3):


def set_array_significant_figures(sig_figs):
"""
Summary.
"""Summary.
Parameters
----------
Expand Down Expand Up @@ -1057,8 +1056,7 @@ def _assert_array_decimal_values_formatting(dec_vals):


def set_array_decimal_values(dec_vals):
"""
Summary.
"""Summary.
Parameters
----------
Expand All @@ -1084,8 +1082,7 @@ def unset_array_decimal_values():


def set_warning_level(warn_level):
"""
Summary.
"""Summary.
Parameters
----------
Expand Down Expand Up @@ -1117,8 +1114,7 @@ def warn(warning_message, stacklevel=0):


def set_nan_policy(warn_level):
"""
Summary.
"""Summary.
Parameters
----------
Expand Down Expand Up @@ -1151,7 +1147,8 @@ def unset_nan_policy():


def set_dynamic_backend(flag): # noqa: D209
"""Set the global dynamic backend setting to the provided flag (True or False)"""
"""Set the global dynamic backend setting to the provided flag (True or
False)"""
global dynamic_backend_stack
if flag not in [True, False]:
raise ValueError("dynamic_backend must be a boolean value (True or False)")
Expand All @@ -1160,8 +1157,7 @@ def set_dynamic_backend(flag): # noqa: D209


def unset_dynamic_backend():
"""
Remove the current dynamic backend setting.
"""Remove the current dynamic backend setting.
Also restore the previous setting (if any)
"""
Expand All @@ -1179,8 +1175,7 @@ def unset_dynamic_backend():

@handle_exceptions
def set_cython_wrappers_mode(flag: bool = True) -> None:
"""
Set the mode of whether to use cython wrappers for functions.
"""Set the mode of whether to use cython wrappers for functions.
Parameter
---------
Expand Down Expand Up @@ -1506,8 +1501,7 @@ def __init__(self):
self.logging_mode_stack.append(logging.WARNING)

def set_logging_mode(self, mode):
"""
Set the current logging mode for Ivy.
"""Set the current logging mode for Ivy.
Possible modes are 'DEBUG', 'INFO', 'WARNING', 'ERROR'.
"""
Expand All @@ -1520,7 +1514,8 @@ def set_logging_mode(self, mode):
self.logging_mode_stack.append(mode)

def unset_logging_mode(self): # noqa: D209
"""Remove the most recently set logging mode, returning to the previous one."""
"""Remove the most recently set logging mode, returning to the previous
one."""
if len(self.logging_mode_stack) > 1:
# Remove the current mode
self.logging_mode_stack.pop()
Expand Down
10 changes: 5 additions & 5 deletions ivy/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,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
----------
Expand Down Expand Up @@ -137,9 +137,9 @@ def transpile(
params_v=None,
v=None
):
"""
Transpiles Callable objects passed as arguments. If args and kwargs are specified,
transpilation is performed eagerly, otherwise, transpilation will happen lazily.
"""Transpiles Callable objects passed as arguments. If args and kwargs are
specified, transpilation is performed eagerly, otherwise, transpilation
will happen lazily.
Parameters
----------
Expand Down
9 changes: 5 additions & 4 deletions ivy/compiler/replace_with.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@


def replace_with(new_func):
"""
Decorate a function/method/attribute to be replaced by another.
"""Decorate a function/method/attribute to be replaced by another.
Parameters
----------
Expand Down Expand Up @@ -43,7 +42,8 @@ def decorator(original_func):


class ReplaceFunction(ast.NodeTransformer):
"""AST Node Transformer to replace function calls, methods, and attributes."""
"""AST Node Transformer to replace function calls, methods, and
attributes."""

def visit_Attribute(self, node):
if (
Expand All @@ -69,7 +69,8 @@ def visit_Call(self, node):


def transform_function(func):
"""Transform the function by replacing its calls based on the replace_map."""
"""Transform the function by replacing its calls based on the
replace_map."""
source = inspect.getsource(func)
tree = ast.parse(source)
transformed_tree = ReplaceFunction().visit(tree)
Expand Down
55 changes: 23 additions & 32 deletions ivy/data_classes/array/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ def relu(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.relu. This method simply wraps the
function, and so the docstring for ivy.relu also applies to this method with
minimal changes.
"""ivy.Array instance method variant of ivy.relu. This method simply
wraps the function, and so the docstring for ivy.relu also applies to
this method with minimal changes.
Parameters
----------
Expand Down Expand Up @@ -55,10 +54,9 @@ def leaky_relu(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.leaky_relu. This method simply wraps
the function, and so the docstring for ivy.leaky_relu also applies to this
method with minimal changes.
"""ivy.Array instance method variant of ivy.leaky_relu. This method
simply wraps the function, and so the docstring for ivy.leaky_relu also
applies to this method with minimal changes.
Parameters
----------
Expand Down Expand Up @@ -97,10 +95,9 @@ def gelu(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.gelu. This method simply wraps the
function, and so the docstring for ivy.gelu also applies to this method with
minimal changes.
"""ivy.Array instance method variant of ivy.gelu. This method simply
wraps the function, and so the docstring for ivy.gelu also applies to
this method with minimal changes.
Parameters
----------
Expand Down Expand Up @@ -138,8 +135,7 @@ def sigmoid(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.sigmoid.
"""ivy.Array instance method variant of ivy.sigmoid.
This method simply wraps the function, and so the docstring for ivy.sigmoid also
applies to this method with minimal changes.
Expand Down Expand Up @@ -178,10 +174,9 @@ def softmax(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.softmax. This method simply wraps the
function, and so the docstring for ivy.softmax also applies to this method with
minimal changes.
"""ivy.Array instance method variant of ivy.softmax. This method simply
wraps the function, and so the docstring for ivy.softmax also applies
to this method with minimal changes.
Parameters
----------
Expand Down Expand Up @@ -219,10 +214,9 @@ def softplus(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.softplus. This method simply wraps the
function, and so the docstring for ivy.softplus also applies to this method with
minimal changes.
"""ivy.Array instance method variant of ivy.softplus. This method
simply wraps the function, and so the docstring for ivy.softplus also
applies to this method with minimal changes.
Parameters
----------
Expand Down Expand Up @@ -276,10 +270,9 @@ def log_softmax(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.log_softmax. This method simply wraps
the function, and so the docstring for ivy.log_softmax also applies to this
method with minimal changes.
"""ivy.Array instance method variant of ivy.log_softmax. This method
simply wraps the function, and so the docstring for ivy.log_softmax
also applies to this method with minimal changes.
Parameters
----------
Expand Down Expand Up @@ -324,10 +317,9 @@ def mish(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
ivy.Array instance method variant of ivy.mish. This method simply wraps the
function, and so the docstring for ivy.mish also applies to this method with
minimal changes.
"""ivy.Array instance method variant of ivy.mish. This method simply
wraps the function, and so the docstring for ivy.mish also applies to
this method with minimal changes.
Parameters
----------
Expand Down Expand Up @@ -356,8 +348,7 @@ def hardswish(
complex_mode: Literal["split", "magnitude", "jax"] = "jax",
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Apply the hardswish activation function element-wise.
"""Apply the hardswish activation function element-wise.
Parameters
----------
Expand Down
Loading

0 comments on commit 207dec0

Please sign in to comment.