Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes 3813 and 3866 -- moves several new functions to the new interface (abs, square, all exp and log, isnan, isinf, isfinite) #3873

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 31 additions & 42 deletions arkouda/numpy/_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,9 @@ def abs(pda: pdarray) -> pdarray:
array([5, 4, 3, 2, 1])
"""
repMsg = generic_msg(
cmd=f"efunc{pda.ndim}D",
cmd=f"abs<{pda.dtype},{pda.ndim}>",
args={
"func": "abs",
"array": pda,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))
Expand Down Expand Up @@ -450,10 +449,9 @@ def isfinite(pda: pdarray) -> pdarray:
array([True, True, False])
"""
repMsg = generic_msg(
cmd=f"efunc{pda.ndim}D",
cmd=f"isfinite<{pda.ndim}>",
args={
"func": "isfinite",
"array": pda,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))
Expand Down Expand Up @@ -487,10 +485,9 @@ def isinf(pda: pdarray) -> pdarray:
array([False, False, True])
"""
repMsg = generic_msg(
cmd=f"efunc{pda.ndim}D",
cmd=f"isinf<{pda.ndim}>",
args={
"func": "isinf",
"array": pda,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))
Expand Down Expand Up @@ -533,10 +530,9 @@ def isnan(pda: pdarray) -> pdarray:
raise TypeError("isnan only supports pdarray of numeric type.")

repMsg = generic_msg(
cmd=f"efunc{pda.ndim}D",
cmd=f"isnan<{pda.ndim}>",
args={
"func": "isnan",
"array": pda,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))
Expand Down Expand Up @@ -580,82 +576,78 @@ def log(pda: pdarray) -> pdarray:
array([0, 3.3219280948873626, 6.6438561897747253])
"""
repMsg = generic_msg(
cmd=f"efunc{pda.ndim}D",
cmd=f"log<{pda.dtype},{pda.ndim}>",
args={
"func": "log",
"array": pda,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))


@typechecked
def log10(x: pdarray) -> pdarray:
def log10(pda: pdarray) -> pdarray:
"""
Return the element-wise base 10 log of the array.

Parameters
__________
x : pdarray
array to compute on
pda : pdarray
array to compute on

Returns
_______
pdarray contain values of the base 10 log
"""
repMsg = generic_msg(
cmd=f"efunc{x.ndim}D",
cmd=f"log10<{pda.dtype},{pda.ndim}>",
args={
"func": "log10",
"array": x,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))


@typechecked
def log2(x: pdarray) -> pdarray:
def log2(pda: pdarray) -> pdarray:
"""
Return the element-wise base 2 log of the array.

Parameters
__________
x : pdarray
array to compute on
pda : pdarray
array to compute on

Returns
_______
pdarray contain values of the base 2 log
"""
repMsg = generic_msg(
cmd=f"efunc{x.ndim}D",
cmd=f"log2<{pda.dtype},{pda.ndim}>",
args={
"func": "log2",
"array": x,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))


@typechecked
def log1p(x: pdarray) -> pdarray:
def log1p(pda: pdarray) -> pdarray:
"""
Return the element-wise natural log of one plus the array.

Parameters
__________
x : pdarray
array to compute on
pda : pdarray
array to compute on

Returns
_______
pdarray contain values of the natural log of one plus the array
"""
repMsg = generic_msg(
cmd=f"efunc{x.ndim}D",
cmd=f"log1p<{pda.dtype},{pda.ndim}>",
args={
"func": "log1p",
"array": x,
"pda": pda,
},
)
return create_pdarray(repMsg)
Expand Down Expand Up @@ -691,10 +683,9 @@ def exp(pda: pdarray) -> pdarray:
33.494295836924771, 13.478894913238722])
"""
repMsg = generic_msg(
cmd=f"efunc{pda.ndim}D",
cmd=f"exp<{pda.dtype},{pda.ndim}>",
args={
"func": "exp",
"array": pda,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))
Expand Down Expand Up @@ -730,10 +721,9 @@ def expm1(pda: pdarray) -> pdarray:
32.494295836924771, 12.478894913238722])
"""
repMsg = generic_msg(
cmd=f"efunc{pda.ndim}D",
cmd=f"expm1<{pda.dtype},{pda.ndim}>",
args={
"func": "expm1",
"array": pda,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))
Expand Down Expand Up @@ -765,10 +755,9 @@ def square(pda: pdarray) -> pdarray:
array([1, 4, 9, 16])
"""
repMsg = generic_msg(
cmd=f"efunc{pda.ndim}D",
cmd=f"square<{pda.dtype},{pda.ndim}>",
args={
"func": "square",
"array": pda,
"pda": pda,
},
)
return create_pdarray(type_cast(str, repMsg))
Expand Down
2 changes: 1 addition & 1 deletion registration-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parameter_classes": {
"array": {
"nd": [1],
"nd": [1,2,3],
ajpotts marked this conversation as resolved.
Show resolved Hide resolved
"dtype": [
"int",
"uint",
Expand Down
Loading
Loading