Skip to content

Commit

Permalink
Fixed output for examples and corrected formatting issues. (#4007)
Browse files Browse the repository at this point in the history
  • Loading branch information
1RyanK authored Feb 6, 2025
1 parent f288772 commit b41b1b3
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions arkouda/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,27 @@ def find(query, space, all_occurrences=False, remove_missing=False):
>>> select_from = ak.arange(10)
>>> arr1 = select_from[ak.randint(0, select_from.size, 20, seed=10)]
>>> arr2 = select_from[ak.randint(0, select_from.size, 20, seed=11)]
# remove some values to ensure we have some values
# which don't appear in the search space
Remove some values to ensure we have some values
which don't appear in the search space
>>> arr2 = arr2[arr2 != 9]
>>> arr2 = arr2[arr2 != 3]
# find with defaults (all_occurrences and remove_missing both False)
Find with defaults (all_occurrences and remove_missing both False)
>>> ak.find(arr1, arr2)
array([-1 -1 -1 0 1 -1 -1 -1 2 -1 5 -1 8 -1 5 -1 -1 11 5 0])
# set remove_missing to True, only difference from default
# is missing values are excluded
>>> ak.find(arr1, arr2, remove_missing=True)
Set remove_missing to True, only difference from default
is missing values are excluded
>>> ak.find(arr1, arr2, remove_missing=True)
array([0 1 2 5 8 5 11 5 0])
# set both remove_missing and all_occurrences to True, missing values
# will be empty segments
Set both remove_missing and all_occurrences to True, missing values
will be empty segments
>>> ak.find(arr1, arr2, remove_missing=True, all_occurrences=True).to_list()
[[],
[],
Expand Down Expand Up @@ -291,20 +296,23 @@ def lookup(keys, values, arguments, fillvalue=-1):
Examples
--------
# Lookup numbers by two-word name
Lookup numbers by two-word name
>>> keys1 = ak.array(['twenty' for _ in range(5)])
>>> keys2 = ak.array(['one', 'two', 'three', 'four', 'five'])
>>> values = ak.array([21, 22, 23, 24, 25])
>>> args1 = ak.array(['twenty', 'thirty', 'twenty'])
>>> args2 = ak.array(['four', 'two', 'two'])
>>> aku.lookup([keys1, keys2], values, [args1, args2])
array([24, -1, 22])
>>> ak.lookup([keys1, keys2], values, [args1, args2])
array([24 -1 22])
Other direction requires an intermediate index
# Other direction requires an intermediate index
>>> revkeys = values
>>> revindices = ak.arange(values.size)
>>> revargs = ak.array([24, 21, 22])
>>> idx = aku.lookup(revkeys, revindices, revargs)
>>> idx = ak.lookup(revkeys, revindices, revargs)
>>> keys1[idx], keys2[idx]
(array(['twenty', 'twenty', 'twenty']),
array(['four', 'one', 'two']))
Expand Down Expand Up @@ -420,10 +428,10 @@ def search_intervals(vals, intervals, tiebreak=None, hierarchical=True):
>>> bi_ends = ak.bigint_from_uint_arrays([ak.cast(a, ak.uint64) for a in ends])
>>> bi_vals = ak.bigint_from_uint_arrays([ak.cast(a, ak.uint64) for a in vals])
>>> bi_starts, bi_ends, bi_vals
(array(["0" "92233720368547758091"]),
array(["92233720368547758090" "166020696663385964564"]),
array(["0" "20" "36893488147419103233" "92233720368547758085" "92233720368547758095"
"110680464442257309696" "110680464442257309708" "166020696663385964574"]))
(array([0 92233720368547758091]),
array([92233720368547758090 166020696663385964564]),
array([0 20 36893488147419103233 92233720368547758085 92233720368547758095
110680464442257309696 110680464442257309708 166020696663385964574]))
>>> ak.search_intervals(bi_vals, (bi_starts, bi_ends))
array([0 0 0 0 1 1 1 -1])
"""
Expand Down

0 comments on commit b41b1b3

Please sign in to comment.