[docs]defmatch(x:Sequence,targets:Union[dict,Sequence],duplicate_method:DUPLICATE_METHOD="first",)->numpy.ndarray:"""Find a matching value of each element of ``x`` in ``target``. Args: x: Squence of values to match. targets: Sequence of targets to be matched against. Alternatively, a dictionary generated by passing a sequence of targets to :py:meth:`~biocutils.map_to_index.map_to_index`. duplicate_method: How to handle duplicate entries in ``targets``. Matches can be reported to the first or last occurrence of duplicates. Returns: Array of length equal to ``x``, containing the integer position of each entry of ``x`` inside ``target``; or -1, if the entry of ``x`` is None or cannot be found in ``target``. """ifnotisinstance(targets,dict):targets=map_to_index(targets,duplicate_method=duplicate_method)indices=numpy.zeros(len(x),dtype=numpy.min_scalar_type(-len(targets)))# get a signed typefori,yinenumerate(x):ifynotintargets:indices[i]=-1else:indices[i]=targets[y]returnindices