forked from Bears-R-Us/arkouda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#3257) Co-authored-by: Amanda Potts <[email protected]>
- Loading branch information
Showing
6 changed files
with
129 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
import arkouda as ak | ||
|
||
NUMERIC_TYPES = [ak.int64, ak.float64, ak.bool, ak.uint64] | ||
NO_BOOL = [ak.int64, ak.float64, ak.uint64] | ||
NO_FLOAT = [ak.int64, ak.bool, ak.uint64] | ||
INT_FLOAT = [ak.int64, ak.float64] | ||
|
||
|
||
class TestNumeric: | ||
@pytest.mark.parametrize("prob_size", pytest.prob_size) | ||
def test_floor_float(self, prob_size): | ||
from arkouda import all as akall | ||
from arkouda.numpy import floor as ak_floor | ||
|
||
a = 0.5 * ak.arange(prob_size, dtype="float64") | ||
a_floor = ak_floor(a) | ||
|
||
expected_size = np.floor((prob_size + 1) / 2).astype("int64") | ||
expected = ak.array(np.repeat(ak.arange(expected_size, dtype="float64").to_ndarray(), 2)) | ||
# To deal with prob_size as an odd number: | ||
expected = expected[0:prob_size] | ||
|
||
assert akall(a_floor == expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import cast as type_cast | ||
|
||
from typeguard import typechecked | ||
|
||
from arkouda.client import generic_msg | ||
from arkouda.pdarrayclass import create_pdarray, pdarray | ||
from arkouda.dtypes import int64 as ak_int64, float64 as ak_float64, bool as ak_bool, uint64 as ak_uint64 | ||
|
||
NUMERIC_TYPES = [ak_int64, ak_float64, ak_bool, ak_uint64] | ||
|
||
__all__ = ["floor"] | ||
|
||
|
||
@typechecked | ||
def floor(pda: pdarray) -> pdarray: | ||
""" | ||
Return the element-wise floor of the array. | ||
Parameters | ||
---------- | ||
pda : pdarray | ||
Returns | ||
------- | ||
pdarray | ||
A pdarray containing floor values of the input array elements | ||
Raises | ||
------ | ||
TypeError | ||
Raised if the parameter is not a pdarray | ||
Examples | ||
-------- | ||
>>> ak.floor(ak.linspace(1.1,5.5,5)) | ||
array([1, 2, 3, 4, 5]) | ||
""" | ||
repMsg = generic_msg( | ||
cmd=f"efunc{pda.ndim}D", | ||
args={ | ||
"func": "floor", | ||
"array": pda, | ||
}, | ||
) | ||
return create_pdarray(type_cast(str, repMsg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters