Skip to content

Commit

Permalink
fix: Fixed order of functions and added missing staticmethod decora…
Browse files Browse the repository at this point in the history
…tor (#27436)
  • Loading branch information
Sai-Suraj-27 committed Dec 4, 2023
1 parent 6a75177 commit d7aedb5
Showing 1 changed file with 53 additions and 52 deletions.
105 changes: 53 additions & 52 deletions ivy/data_classes/container/experimental/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,57 +1252,6 @@ def static_unsorted_segment_mean(
map_sequences=map_sequences,
)

def static_polyval(
coeffs: ivy.Container,
x: Union[ivy.Container, int, float],
*,
key_chains: Optional[Union[List[str], Dict[str, str]]] = None,
to_apply: bool = True,
prune_unapplied: bool = False,
map_sequences: bool = False,
) -> ivy.Container:
r"""
ivy.Container static method variant of ivy.polyval. This method simply wraps the
function, and so the docstring for ivy.polyval also applies to this method with
minimal changes.
Evaluate and return a polynomial at specific given values.
Parameters
----------
coeffs
Polynomial coefficients (including zero) from highest degree
to constant term.
x
The value of the indeterminate variable at which to evaluate the polynomial.
key_chains
The key-chains to apply or not apply the method to. Default is ``None``.
to_apply
If True, the method will be applied to key_chains, otherwise key_chains
will be skipped. Default is ``True``.
prune_unapplied
Whether to prune key_chains for which the function was not applied.
Default is ``False``.
map_sequences
Whether to also map method to sequences (lists, tuples).
Default is ``False``.
Returns
-------
ret
Output container containing simplified result of substituting x in the
coefficients - final value of polynomial.
"""
return ContainerBase.cont_multi_map_in_function(
"polyval",
coeffs,
x,
key_chains=key_chains,
to_apply=to_apply,
prune_unapplied=prune_unapplied,
map_sequences=map_sequences,
)

def unsorted_segment_mean(
self: ivy.Container,
segment_ids: Union[ivy.Array, ivy.Container],
Expand Down Expand Up @@ -1359,6 +1308,58 @@ def unsorted_segment_mean(
num_segments,
)

@staticmethod
def static_polyval(
coeffs: ivy.Container,
x: Union[ivy.Container, int, float],
*,
key_chains: Optional[Union[List[str], Dict[str, str]]] = None,
to_apply: bool = True,
prune_unapplied: bool = False,
map_sequences: bool = False,
) -> ivy.Container:
r"""
ivy.Container static method variant of ivy.polyval. This method simply wraps the
function, and so the docstring for ivy.polyval also applies to this method with
minimal changes.
Evaluate and return a polynomial at specific given values.
Parameters
----------
coeffs
Polynomial coefficients (including zero) from highest degree
to constant term.
x
The value of the indeterminate variable at which to evaluate the polynomial.
key_chains
The key-chains to apply or not apply the method to. Default is ``None``.
to_apply
If True, the method will be applied to key_chains, otherwise key_chains
will be skipped. Default is ``True``.
prune_unapplied
Whether to prune key_chains for which the function was not applied.
Default is ``False``.
map_sequences
Whether to also map method to sequences (lists, tuples).
Default is ``False``.
Returns
-------
ret
Output container containing simplified result of substituting x in the
coefficients - final value of polynomial.
"""
return ContainerBase.cont_multi_map_in_function(
"polyval",
coeffs,
x,
key_chains=key_chains,
to_apply=to_apply,
prune_unapplied=prune_unapplied,
map_sequences=map_sequences,
)

def polyval(
self: ivy.Container,
coeffs: ivy.Container,
Expand Down Expand Up @@ -1388,4 +1389,4 @@ def polyval(
Output container containing simplified result of substituting x in the
coefficients - final value of polynomial.
"""
return self.static_polyval(self, coeffs, x)
return self.static_polyval(coeffs, x)

0 comments on commit d7aedb5

Please sign in to comment.