-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #778 from Labelbox/develop
Release 3.31.0
- Loading branch information
Showing
35 changed files
with
2,277 additions
and
336 deletions.
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
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,32 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel, validator | ||
|
||
from labelbox.exceptions import ConfidenceNotSupportedException | ||
|
||
|
||
class ConfidenceMixin(BaseModel): | ||
confidence: Optional[float] = None | ||
|
||
@validator('confidence') | ||
def confidence_valid_float(cls, value): | ||
if value is None: | ||
return value | ||
if not isinstance(value, (int, float)) or not 0 <= value <= 1: | ||
raise ValueError('must be a number within [0,1] range') | ||
return value | ||
|
||
def dict(self, *args, **kwargs): | ||
res = super().dict(*args, **kwargs) | ||
if 'confidence' in res and res['confidence'] is None: | ||
res.pop('confidence') | ||
return res | ||
|
||
|
||
class ConfidenceNotSupportedMixin: | ||
|
||
def __new__(cls, *args, **kwargs): | ||
if 'confidence' in kwargs: | ||
raise ConfidenceNotSupportedException( | ||
'Confidence is not supported for this annotaiton type yet') | ||
return super().__new__(cls) |
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
Oops, something went wrong.