Skip to content

Commit 29b0949

Browse files
author
Matt Sokoloff
committed
Merge branch 'develop' of https://github.com/Labelbox/labelbox-python into AL-695-users
2 parents b85714f + cf226eb commit 29b0949

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
# Version 3.11.1 (2022-01-10)
3+
## Fix
4+
* Make `TypedArray` class compatible with `numpy` versions `>= 1.22.0`
5+
* `project.upsert_review_queue` quotas can now be in the inclusive range [0,1]
26

37
# Version 3.11.0 (2021-12-15)
48

labelbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "labelbox"
2-
__version__ = "3.11.0"
2+
__version__ = "3.11.1"
33

44
from labelbox.schema.project import Project
55
from labelbox.client import Client
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import sys
2-
import logging
3-
from typing import Generic, TypeVar
4-
from typing_extensions import Annotated
2+
from typing import Generic, TypeVar, Any
53

4+
from typing_extensions import Annotated
5+
from packaging import version
66
from pydantic import Field
77
from pydantic.fields import ModelField
88
import numpy as np
99

1010
Cuid = Annotated[str, Field(min_length=25, max_length=25)]
1111

1212
DType = TypeVar('DType')
13-
14-
logger = logging.getLogger(__name__)
13+
DShape = TypeVar('DShape')
1514

1615

17-
class TypedArray(np.ndarray, Generic[DType]):
16+
class _TypedArray(np.ndarray, Generic[DType, DShape]):
1817

1918
@classmethod
2019
def __get_validators__(cls):
@@ -26,12 +25,19 @@ def validate(cls, val, field: ModelField):
2625
raise TypeError(f"Expected numpy array. Found {type(val)}")
2726

2827
if sys.version_info.minor > 6:
29-
actual_dtype = field.sub_fields[0].type_.__args__[0]
28+
actual_dtype = field.sub_fields[-1].type_.__args__[0]
3029
else:
31-
actual_dtype = field.sub_fields[0].type_.__values__[0]
30+
actual_dtype = field.sub_fields[-1].type_.__values__[0]
3231

3332
if val.dtype != actual_dtype:
3433
raise TypeError(
3534
f"Expected numpy array have type {actual_dtype}. Found {val.dtype}"
3635
)
3736
return val
37+
38+
39+
if version.parse(np.__version__) >= version.parse('1.22.0'):
40+
from numpy.typing import _GenericAlias
41+
TypedArray = _GenericAlias(_TypedArray, (Any, DType))
42+
else:
43+
TypedArray = _TypedArray[Any, DType]

labelbox/schema/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def upsert_review_queue(self, quota_factor):
681681
to reinitiate. Between 0 and 1.
682682
"""
683683

684-
if not 0. < quota_factor < 1.:
684+
if not 0. <= quota_factor <= 1.:
685685
raise ValueError("Quota factor must be in the range of [0,1]")
686686

687687
id_param = "projectId"

0 commit comments

Comments
 (0)