Skip to content

Commit

Permalink
test more corner cases in the allocator acquire/release code
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoldbaum committed Nov 20, 2023
1 parent 5718197 commit 5110e5d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions stringdtype/tests/test_stringdtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,17 +811,25 @@ def func(arr):
rnd = rng.random()
# either write to random locations in the array, compute a ufunc, or
# re-initialize the array
if rnd < 0.3333:
if rnd < 0.25:
num = np.random.randint(0, arr.size)
arr[num] = arr[num] + "hello"
elif rnd < 0.6666:
np.add(arr, arr)
elif rnd < 0.5:
if rnd < 0.375:
np.add(arr, arr)
else:
np.add(arr, arr, out=arr)
elif rnd < 0.75:
if rnd < 0.875:
np.multiply(arr, np.int64(2))
else:
np.multiply(arr, np.int64(2), out=arr)
else:
arr[:] = random_string_list

with concurrent.futures.ThreadPoolExecutor(max_workers=8) as tpe:
arr = np.array(random_string_list, dtype=dtype)
futures = [tpe.submit(func, arr) for _ in range(100)]
futures = [tpe.submit(func, arr) for _ in range(500)]

for f in futures:
f.result()

0 comments on commit 5110e5d

Please sign in to comment.