Skip to content

Commit

Permalink
Closes Bears-R-Us#3281 rename bool to bool_ to match numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpotts committed Jul 1, 2024
1 parent ed9d502 commit b183b85
Show file tree
Hide file tree
Showing 46 changed files with 187 additions and 172 deletions.
4 changes: 2 additions & 2 deletions PROTO_tests/tests/dataframe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ def test_dropna(self):
)

def test_memory_usage(self):
dtypes = [ak.int64, ak.float64, ak.bool]
dtypes = [ak.int64, ak.float64, ak.bool_]
data = dict([(str(t), ak.ones(5000, dtype=ak.int64).astype(t)) for t in dtypes])
df = ak.DataFrame(data)
ak_memory_usage = df.memory_usage()
Expand Down Expand Up @@ -1313,7 +1313,7 @@ def test_sample_flags(self):
@pytest.mark.parametrize("size", pytest.prob_size)
def test_head_tail(self, size):

bool_col = ak.full(size, False, dtype=ak.bool)
bool_col = ak.full(size, False, dtype=ak.bool_)
bool_col[::2] = True

df = ak.DataFrame(
Expand Down
8 changes: 4 additions & 4 deletions PROTO_tests/tests/dtypes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_nbytes(self, size):
ak.dtypes.uint64,
ak.dtypes.int64,
ak.dtypes.float64,
ak.dtypes.bool,
ak.dtypes.bool_,
]

for dt in dtype_list:
Expand All @@ -109,7 +109,7 @@ def test_nbytes(self, size):
def test_pdarrays_datatypes(self):
assert dtypes.dtype("int64") == ak.array(np.arange(10)).dtype
assert dtypes.dtype("uint64") == ak.array(np.arange(10), ak.uint64).dtype
assert dtypes.dtype("bool") == ak.ones(10, ak.bool).dtype
assert dtypes.dtype("bool") == ak.ones(10, ak.bool_).dtype
assert dtypes.dtype("float64") == ak.ones(10).dtype
assert dtypes.dtype("str") == ak.random_strings_uniform(1, 16, size=10).dtype

Expand Down Expand Up @@ -179,13 +179,13 @@ def test_DtypeEnum(self):

assert (
frozenset(
{"bool", "float", "float64", "int", "int64", "uint", "uint64", "uint8", "bigint", "str"}
{"bool_", "float", "float64", "int", "int64", "uint", "uint64", "uint8", "bigint", "str"}
)
== ak.ARKOUDA_SUPPORTED_DTYPES
)

def test_NumericDTypes(self):
num_types = frozenset(["bool", "float", "float64", "int", "int64", "uint64", "bigint"])
num_types = frozenset(["bool", "bool_", "float", "float64", "int", "int64", "uint64", "bigint"])
assert num_types == dtypes.NumericDTypes

def test_SeriesDTypes(self):
Expand Down
12 changes: 6 additions & 6 deletions PROTO_tests/tests/groupby_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ def test_head_aggregation(self, size, dtype):

if dtype is ak.str_:
v = ak.random_strings_uniform(size=size, minlen=1, maxlen=2)
elif dtype is ak.bool:
v = ak.full(size, False, dtype=ak.bool)
elif dtype is ak.bool_:
v = ak.full(size, False, dtype=ak.bool_)
v[::2] = True
else:
v = ak.arange(size, dtype=dtype)
Expand Down Expand Up @@ -706,7 +706,7 @@ def test_head_aggregation(self, size, dtype):
unique_keys, values = g.head(v, 2, return_indices=False)
assert len(values) == len(expected_values)
assert ak.all(unique_keys == ak.array([0, 1, 2]))
if dtype == ak.bool:
if dtype == ak.bool_:
assert aksum(values) == aksum(expected_values)
else:
assert set(values.to_list()) == set(expected_values.to_list())
Expand All @@ -722,8 +722,8 @@ def test_tail_aggregation(self, size, dtype):

if dtype is ak.str_:
v = ak.random_strings_uniform(size=size, minlen=1, maxlen=2)
elif dtype is ak.bool:
v = ak.full(size, False, dtype=ak.bool)
elif dtype is ak.bool_:
v = ak.full(size, False, dtype=ak.bool_)
v[::2] = True
else:
v = ak.arange(size, dtype=dtype)
Expand Down Expand Up @@ -756,7 +756,7 @@ def test_tail_aggregation(self, size, dtype):
unique_keys, values = g.tail(v, 2, return_indices=False)
assert len(values) == len(expected_values)
assert ak.all(unique_keys == ak.array([0, 1, 2]))
if dtype == ak.bool:
if dtype == ak.bool_:
assert aksum(values) == aksum(expected_values)
else:
assert set(values.to_list()) == set(expected_values.to_list())
Expand Down
8 changes: 4 additions & 4 deletions PROTO_tests/tests/indexing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import arkouda as ak

NUM_TYPES = [ak.int64, ak.uint64, ak.float64, ak.bool, ak.bigint]
NUM_TYPES = [ak.int64, ak.uint64, ak.float64, ak.bool_, ak.bigint]


def key_arrays(size):
Expand All @@ -17,7 +17,7 @@ def value_array(dtype, size):
return ak.randint(-size, size, size, dtype=dtype)
elif dtype is ak.uint64:
return ak.randint(0, size, size, dtype=dtype)
elif dtype is ak.bool:
elif dtype is ak.bool_:
return (ak.randint(0, size, size) % 2) == 0
elif dtype is ak.bigint:
return ak.randint(0, size, size, dtype=ak.uint64) + 2**200
Expand All @@ -31,7 +31,7 @@ def value_scalar(dtype, size):
return ak.randint(-size, 0, 1, dtype=dtype)
elif dtype is ak.uint64:
return ak.randint(2**63, 2**64, 1, dtype=dtype)
elif dtype is ak.bool:
elif dtype is ak.bool_:
return (ak.randint(0, 2, 1) % 2) == 0
elif dtype is ak.bigint:
return ak.randint(0, size, 1, dtype=ak.uint64) + 2**200
Expand All @@ -52,7 +52,7 @@ def test_pdarray_uint_indexing(self, prob_size, dtype):
@pytest.mark.parametrize("prob_size", pytest.prob_size)
def test_bool_indexing(self, prob_size):
u = value_array(ak.uint64, prob_size)
b = value_array(ak.bool, prob_size)
b = value_array(ak.bool_, prob_size)
assert u[b].to_list() == ak.cast(u, ak.int64)[b].to_list()
assert u[b].to_list() == ak.cast(u, ak.bigint)[b].to_list()

Expand Down
4 changes: 2 additions & 2 deletions PROTO_tests/tests/io_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def make_multi_dtype_dict():
"c_3": ak.arange(2**63 + 3, 2**63 + 7, dtype=ak.uint64),
"c_4": ak.SegArray(ak.array([0, 5, 10, 10]), ak.arange(2**63, 2**63 + 15, dtype=ak.uint64)),
"c_5": ak.array([False, True, False, False]),
"c_6": ak.SegArray(ak.array([0, 0, 5, 10]), ak.randint(0, 1, 15, dtype=ak.bool)),
"c_6": ak.SegArray(ak.array([0, 0, 5, 10]), ak.randint(0, 1, 15, dtype=ak.bool_)),
"c_7": ak.array([-0.0, np.finfo(np.float64).min, np.nan, np.inf]),
"c_8": ak.SegArray(
ak.array([0, 9, 14, 14]),
Expand Down Expand Up @@ -1145,7 +1145,7 @@ def test_hdf_overwrite_pdarray(self):
with tempfile.TemporaryDirectory(dir=TestHDF5.hdf_test_base_tmp) as tmp_dirname:
file_name = f"{tmp_dirname}/pda_test"
a.to_hdf(file_name)
for size, dtype in [(15, ak.uint64), (150, ak.float64), (1000, ak.bool)]:
for size, dtype in [(15, ak.uint64), (150, ak.float64), (1000, ak.bool_)]:
b = ak.arange(size, dtype=dtype)
b.update_hdf(file_name)
data = ak.read_hdf(f"{file_name}*").popitem()[1]
Expand Down
2 changes: 1 addition & 1 deletion PROTO_tests/tests/message_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TestJSONArgs:
SCALAR_TYPES = [int, float, bool, str]
# The types below are support in arkouda, as noted in serverConfig.json. This may be
# the same issue noted in the above comment.
SUPPORTED_TYPES = [ak.bool, ak.uint64, ak.int64, ak.bigint, ak.uint8, ak.float64]
SUPPORTED_TYPES = [ak.bool_, ak.uint64, ak.int64, ak.bigint, ak.uint8, ak.float64]

@pytest.mark.parametrize("dtype", SCALAR_TYPES)
def test_scalar_args(self, dtype):
Expand Down
16 changes: 8 additions & 8 deletions PROTO_tests/tests/numeric_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from arkouda.dtypes import npstr
from math import isclose

NUMERIC_TYPES = [ak.int64, ak.float64, ak.bool, ak.uint64]
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]
NO_FLOAT = [ak.int64, ak.bool_, ak.uint64]
INT_FLOAT = [ak.int64, ak.float64]

# There are many ways to create a vector of alternating values.
Expand Down Expand Up @@ -56,7 +56,7 @@ def alternatingTF(n):

# as noted in serverConfig.json, only these types are supported

SUPPORTED_TYPES = [ak.bool, ak.uint64, ak.int64, ak.bigint, ak.uint8, ak.float64]
SUPPORTED_TYPES = [ak.bool_, ak.uint64, ak.int64, ak.bigint, ak.uint8, ak.float64]


NP_TRIG_ARRAYS = {
Expand All @@ -67,7 +67,7 @@ def alternatingTF(n):
np.array([np.nan, -np.inf, -0.0, 0.0, np.inf]),
]
),
ak.bool: alternate(True, False, 10),
ak.bool_: alternate(True, False, 10),
ak.uint64: np.arange(2**64 - 10, 2**64, dtype=np.uint64),
}

Expand All @@ -83,7 +83,7 @@ def alternatingTF(n):
}

ROUNDTRIP_CAST = [
(ak.bool, ak.bool),
(ak.bool_, ak.bool_),
(ak.int64, ak.int64),
(ak.int64, ak.float64),
(ak.int64, npstr),
Expand Down Expand Up @@ -189,12 +189,12 @@ def test_cast(self, prob_size, cast_to):
ak.int64: ak.randint(-(2**48), 2**48, prob_size),
ak.uint64: ak.randint(0, 2**48, prob_size, dtype=ak.uint64),
ak.float64: ak.randint(0, 1, prob_size, dtype=ak.float64),
ak.bool: ak.randint(0, 2, prob_size, dtype=ak.bool),
ak.bool_: ak.randint(0, 2, prob_size, dtype=ak.bool_),
ak.str_: ak.cast(ak.randint(0, 2**48, prob_size), "str"),
}

for t1, orig in arrays.items():
if (t1 == ak.float64 and cast_to == ak.bigint) or (t1 == ak.str_ and cast_to == ak.bool):
if (t1 == ak.float64 and cast_to == ak.bigint) or (t1 == ak.str_ and cast_to == ak.bool_):
# we don't support casting a float to a bigint
# we do support str to bool, but it's expected to contain "true/false" not numerics
continue
Expand Down Expand Up @@ -231,7 +231,7 @@ def test_str_cast_errors(self, num_type):
]
)
ans = np.array([1.1, 2.2, np.nan, np.nan, 5.5, 6.6e-6, 78.91e4, 6.0, np.nan])
elif num_type == ak.bool:
elif num_type == ak.bool_:
strarr = ak.array(
[
"True",
Expand Down
4 changes: 2 additions & 2 deletions PROTO_tests/tests/numpy/numpy_numeric_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import arkouda as ak

NUMERIC_TYPES = [ak.int64, ak.float64, ak.bool, ak.uint64]
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]
NO_FLOAT = [ak.int64, ak.bool_, ak.uint64]
INT_FLOAT = [ak.int64, ak.float64]


Expand Down
18 changes: 9 additions & 9 deletions PROTO_tests/tests/pdarray_creation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def test_arange_misc(self):

# test correct conversion to bool
expected_bool = [False, True, True, True, True]
ak_arange_bool = ak.arange(0, 10, 2, dtype=ak.bool)
ak_arange_bool = ak.arange(0, 10, 2, dtype=ak.bool_)
assert expected_bool == ak_arange_bool.to_list()
assert ak.bool == ak_arange_bool.dtype
assert ak.bool_ == ak_arange_bool.dtype

# test int_scalars covers uint8, uint16, uint32
uint_array = ak.arange(np.uint8(1), np.uint16(1000), np.uint32(1))
Expand Down Expand Up @@ -256,7 +256,7 @@ def test_randint_with_seed(self):
assert ans == values.to_list()

bools = [False, True, True, True, True, False, True, True, True, True]
values = ak.randint(1, 5, 10, dtype=ak.bool, seed=2)
values = ak.randint(1, 5, 10, dtype=ak.bool_, seed=2)
assert values.to_list() == bools

values = ak.randint(1, 5, 10, dtype=bool, seed=2)
Expand Down Expand Up @@ -295,7 +295,7 @@ def test_uniform(self, size):
assert (uint_arr == int_arr).all()

@pytest.mark.parametrize("size", pytest.prob_size)
@pytest.mark.parametrize("dtype", [ak.int64, float, ak.float64, bool, ak.bool, ak.bigint])
@pytest.mark.parametrize("dtype", [ak.int64, float, ak.float64, bool, ak.bool_, ak.bigint])
def test_zeros_dtype(self, size, dtype):
zeros = ak.zeros(size, dtype)
assert isinstance(zeros, ak.pdarray)
Expand All @@ -317,7 +317,7 @@ def test_zeros_misc(self):
for arg in np.uint8(5), np.uint16(5), np.uint32(5), str(5):
assert (int_arr == ak.zeros(arg, dtype=ak.int64)).all()

@pytest.mark.parametrize("dtype", [int, ak.int64, float, ak.float64, bool, ak.bool, ak.bigint])
@pytest.mark.parametrize("dtype", [int, ak.int64, float, ak.float64, bool, ak.bool_, ak.bigint])
@pytest.mark.parametrize("size", pytest.prob_size)
def test_ones_dtype(self, size, dtype):
ones = ak.ones(size, dtype)
Expand All @@ -341,7 +341,7 @@ def test_ones_misc(self):
assert (int_arr == ak.ones(arg, dtype=ak.int64)).all()

@pytest.mark.parametrize("size", pytest.prob_size)
@pytest.mark.parametrize("dtype", [ak.int64, ak.float64, ak.bool, ak.bigint])
@pytest.mark.parametrize("dtype", [ak.int64, ak.float64, ak.bool_, ak.bigint])
def test_ones_like(self, size, dtype):
ones_arr = ak.ones(size, dtype)
ones_like_arr = ak.ones_like(ones_arr)
Expand All @@ -350,7 +350,7 @@ def test_ones_like(self, size, dtype):
assert (1 == ones_like_arr).all()

@pytest.mark.parametrize("size", pytest.prob_size)
@pytest.mark.parametrize("dtype", [int, ak.int64, ak.uint64, float, ak.float64, bool, ak.bool])
@pytest.mark.parametrize("dtype", [int, ak.int64, ak.uint64, float, ak.float64, bool, ak.bool_])
def test_full_dtype(self, size, dtype):
type_full = ak.full(size, 1, dtype)
assert isinstance(type_full, ak.pdarray)
Expand Down Expand Up @@ -387,7 +387,7 @@ def test_full_misc(self):
assert (int_arr == ak.full(*args, dtype=int)).all()

@pytest.mark.parametrize("size", pytest.prob_size)
@pytest.mark.parametrize("dtype", [int, ak.int64, ak.uint64, float, ak.float64, bool, ak.bool])
@pytest.mark.parametrize("dtype", [int, ak.int64, ak.uint64, float, ak.float64, bool, ak.bool_])
def test_full_like(self, size, dtype):
full_arr = ak.full(size, 1, dtype)
full_like_arr = ak.full_like(full_arr, 1)
Expand All @@ -396,7 +396,7 @@ def test_full_like(self, size, dtype):
assert (full_like_arr == 1).all()

@pytest.mark.parametrize("size", pytest.prob_size)
@pytest.mark.parametrize("dtype", [int, ak.int64, ak.uint64, float, ak.float64, bool, ak.bool])
@pytest.mark.parametrize("dtype", [int, ak.int64, ak.uint64, float, ak.float64, bool, ak.bool_])
def test_zeros_like(self, size, dtype):
zeros_arr = ak.zeros(size, dtype)
zeros_like_arr = ak.zeros_like(zeros_arr)
Expand Down
6 changes: 3 additions & 3 deletions PROTO_tests/tests/random_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ def test_legacy_randint(self):
test_array = ak.random.randint(0, 1, 3, dtype=ak.float64)
assert ak.float64 == test_array.dtype

test_array = ak.random.randint(0, 1, 5, dtype=ak.bool)
assert ak.bool == test_array.dtype
test_array = ak.random.randint(0, 1, 5, dtype=ak.bool_)
assert ak.bool_ == test_array.dtype

test_ndarray = test_array.to_ndarray()

Expand Down Expand Up @@ -423,7 +423,7 @@ def test_legacy_randint_with_seed(self):
4.0337935981006172,
] == values.to_list()

values = ak.random.randint(1, 5, 10, dtype=ak.bool, seed=2)
values = ak.random.randint(1, 5, 10, dtype=ak.bool_, seed=2)
assert [False, True, True, True, True, False, True, True, True, True] == values.to_list()

values = ak.random.randint(1, 5, 10, dtype=bool, seed=2)
Expand Down
Loading

0 comments on commit b183b85

Please sign in to comment.