-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat(weave): Add support for jpegs and pngs #3304
Merged
+146
−28
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d6d0590
test
andrewtruong f96f9ab
test
andrewtruong e0a1b4e
test
andrewtruong 914786f
test
andrewtruong 0b2839d
test
andrewtruong fe99386
test
andrewtruong 34e92ba
test
andrewtruong 6b70523
test
andrewtruong 5adf87b
test
andrewtruong f15fde5
test
andrewtruong 4ecc75d
test
andrewtruong b05e383
test
andrewtruong 662a8e1
bump
andrewtruong ecf635f
test
andrewtruong 5714bc9
Merge branch 'master' into andrew/pil
andrewtruong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Iterator, MutableMapping | ||
from typing import Any, TypeVar | ||
|
||
KT = TypeVar("KT") | ||
VT = TypeVar("VT") | ||
|
||
|
||
class InvertableDict(MutableMapping[KT, VT]): | ||
"""A bijective mapping that behaves like a dict. | ||
|
||
Invert the dict using the `inv` property. | ||
""" | ||
|
||
def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
self._forward = dict(*args, **kwargs) | ||
self._backward: dict[VT, KT] = {} | ||
for key, value in self._forward.items(): | ||
if value in self._backward: | ||
raise ValueError(f"Duplicate value found: {value}") | ||
self._backward[value] = key | ||
|
||
def __getitem__(self, key: KT) -> VT: | ||
return self._forward[key] | ||
|
||
def __setitem__(self, key: KT, value: VT) -> None: | ||
if key in self._forward: | ||
del self._backward[self._forward[key]] | ||
if value in self._backward: | ||
raise ValueError(f"Duplicate value found: {value}") | ||
self._forward[key] = value | ||
self._backward[value] = key | ||
|
||
def __delitem__(self, key: KT) -> None: | ||
value = self._forward.pop(key) | ||
del self._backward[value] | ||
|
||
def __iter__(self) -> Iterator[KT]: | ||
return iter(self._forward) | ||
|
||
def __len__(self) -> int: | ||
return len(self._forward) | ||
|
||
def __repr__(self) -> str: | ||
return repr(self._forward) | ||
|
||
def __contains__(self, key: Any) -> bool: | ||
return key in self._forward | ||
|
||
@property | ||
def inv(self) -> InvertableDict[VT, KT]: | ||
res = InvertableDict[VT, KT]() | ||
res._forward = self._backward | ||
res._backward = self._forward | ||
return res |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not correct since you are not guaranteed to find the key. This cast is invalid and causes line 37 to be incorrect.