Skip to content

Commit

Permalink
Closes Bears-R-Us#3462 deprecate string_test.py (Bears-R-Us#3608)
Browse files Browse the repository at this point in the history
Co-authored-by: Amanda Potts <ajpotts@users.noreply.github.com>
  • Loading branch information
ajpotts and ajpotts authored Aug 5, 2024
1 parent dbb6612 commit fa620c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
29 changes: 28 additions & 1 deletion PROTO_tests/tests/string_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

import arkouda as ak

ak.verbose = False
N = 100
UNIQUE = N // 4


class TestString:
Gremlins = namedtuple(
Expand Down Expand Up @@ -816,7 +820,9 @@ def test_get_fixes(self):
assert [x[len(x) - n :] for x in a if len(x) >= n] == suffix.to_list()

def test_encoding(self):
idna_strings = ak.array(["Bücher.example", "ドメイン.テスト", "домен.испытание", "Königsgäßchen"])
idna_strings = ak.array(
["Bücher.example", "ドメイン.テスト", "домен.испытание", "Königsgäßchen"]
)
expected = ak.array(
[
"xn--bcher-kva.example",
Expand Down Expand Up @@ -879,3 +885,24 @@ def test_string_broadcast(self):
manual_broadcasted = ak.broadcast(g.segments, str_vals, permutation=g.permutation)
assert (gb_broadcasted == str_broadcast_ans).all()
assert (manual_broadcasted == str_broadcast_ans).all()

@pytest.mark.parametrize("size", pytest.prob_size)
def test_in1d(self, size):
base_words, _ = self.base_words(size)
strings = self.get_strings(size, base_words)
cat = ak.Categorical(strings)

more_choices = ak.randint(0, UNIQUE, 100)
akwords = strings
more_words = akwords.to_ndarray()
matches = ak.in1d(strings, akwords)
catmatches = ak.in1d(cat, akwords)
assert (matches == catmatches).all()
# Every word in matches should be in the target set
for word in strings[matches].to_ndarray():
assert word in more_words
# Exhaustively find all matches to make sure we didn't miss any
inds = ak.zeros(size, dtype=ak.bool_)
for word in more_words:
inds |= strings == word
assert (inds == matches).all()
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ testpaths =
tests/pdarray_creation_test.py
tests/regex_test.py
tests/sort_test.py
tests/string_test.py
tests/symbol_table_test.py
tests/where_test.py
norecursedirs = .git dist build *egg* tests/deprecated/* PROTO_test
Expand Down
File renamed without changes.

0 comments on commit fa620c2

Please sign in to comment.