FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Accept `Sequence` instead of `List` by jangop · Pull Request #290 · openai/CLIP · GitHub

/ CLIP Public

Accept Sequence instead of List - #290

Open
jangop wants to merge 1 commit into
openai:mainfrom
jangop:patch-1
Open

jangop wants to merge 1 commit into
openai:mainfrom
jangop:patch-1

Conversation

jangop commented Sep 14, 2022

Copy link
Copy Markdown

This is minor, I know. tokenize simply iterates over texts, so in addition to list, tuple is fine. The intended type hint for this is Sequence.

I am not sure which version of Python this project targets, but judging from the other type hints in this file, I am going to assume <3.9. Otherwise, I would suggest importing Sequence from collections.abc instead of typing.

This is minor, I know. `tokenize` simply iterates over `texts`, so in addition to `list`, `tuple` is fine. The intended type hint for this is `Sequence`.

I am not sure which version of Python this project targets, but judging from the other type hints in this file, I am going to assume `<3.9`. Otherwise, I would suggest importing `Sequence` from `collections.abc` instead of `typing`.
Comment thread clip/clip.py


def tokenize(texts: Union[str, List[str]], context_length: int = 77, truncate: bool = False) -> Union[torch.IntTensor, torch.LongTensor]:
def tokenize(texts: Union[str, Sequence[str]], context_length: int = 77, truncate: bool = False) -> Union[torch.IntTensor, torch.LongTensor]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The docstring at line 203 should be modified too.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL