Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend IndexMap.to_idxs(...) to any shape #159

Open
M-Lampert opened this issue Apr 10, 2024 · 0 comments
Open

Extend IndexMap.to_idxs(...) to any shape #159

M-Lampert opened this issue Apr 10, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@M-Lampert
Copy link
Contributor

The method IndexMap.to_idxs(...) is meant as a shortcut if you want to convert an iterable of ids to the corresponding idx. In some cases one might want to input an numpy.array or a torch.Tensor with a specific shape. Currently we only allow conversions for one dimensional iterable objects but it would be great if you could input any shape and the output has the same shape and potentially also type. For the other direction (i.e. to_ids(....)) it would also make sense.
Example for the desired behaviour:

>>> mapping = IndexMap(["a", "b", "c"])
>>> print(mapping.to_idxs(np.array([
>>>         ["a", "a", "b"],
>>>         ["b", "c", "c"]]))
np.array([
   [0, 0, 1],
   [1, 2, 2]])
@M-Lampert M-Lampert added the enhancement New feature or request label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants