Skip to content

Commit 08bcc1b

Browse files
committed
updates to documentation. also, Line should only be 2 or more Points
1 parent 2069945 commit 08bcc1b

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

labelbox/data/annotation_types/classification/classification.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,30 @@ class ClassificationAnswer(FeatureSchema):
2929

3030

3131
class Radio(BaseModel):
32-
""" A classification with only one selected option allowed """
32+
""" A classification with only one selected option allowed
33+
34+
>>> Radio(answer = ClassificationAnswer(name = "dog"))
35+
36+
"""
3337
answer: ClassificationAnswer
3438

3539

3640
class Checklist(_TempName):
37-
""" A classification with many selected options allowed """
41+
""" A classification with many selected options allowed
42+
43+
>>> Checklist(answer = [ClassificationAnswer(name = "cloudy")])
44+
45+
"""
3846
name: Literal["checklist"] = "checklist"
3947
answer: List[ClassificationAnswer]
4048

4149

4250
class Text(BaseModel):
43-
""" Free form text """
51+
""" Free form text
52+
53+
>>> Text(answer = "some text answer")
54+
55+
"""
4456
answer: str
4557

4658

labelbox/data/annotation_types/data/text.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99

1010
class TextData(BaseData):
1111
"""
12-
Represents text data
12+
Represents text data. Requires arg file_path, text, or url
13+
14+
>>> TextData(text="")
15+
16+
Args:
17+
file_path (str)
18+
text (str)
19+
url (str)
1320
"""
1421
file_path: Optional[str] = None
1522
text: Optional[str] = None

labelbox/data/annotation_types/geometry/line.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ class Line(Geometry):
1414
Args:
1515
points (List[Point]): A list of `Point` geometries
1616
17+
>>> Line(points = [Point(x=3,y=4), Point(x=3,y=5)])
18+
1719
"""
1820
points: List[Point]
1921

2022
@property
2123
def geometry(self) -> geojson.MultiLineString:
22-
return geojson.MultiLineString(
23-
[[[point.x, point.y] for point in self.points]])
24+
return geojson.MultiLineString([[[point.x, point.y]
25+
for point in self.points]])
2426

2527
def draw(self,
2628
height: Optional[int] = None,
@@ -47,3 +49,12 @@ def draw(self,
4749
False,
4850
color=color,
4951
thickness=thickness)
52+
53+
@validator('points')
54+
def is_geom_valid(cls, points):
55+
if len(points) < 2:
56+
raise ValueError(
57+
f"A line must have at least 2 points to be valid. Found {points}"
58+
)
59+
60+
return points

0 commit comments

Comments
 (0)