Skip to content

Commit 0b81083

Browse files
authored
Merge pull request #334 from Labelbox/jtso/update_docstrings
updates to documentation. also, Line should only be 2 or more Points
2 parents 47bab9d + 612f573 commit 0b81083

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import geojson
44
import numpy as np
55
import cv2
6+
from pydantic import validator
67

78
from .point import Point
89
from .geometry import Geometry
@@ -14,6 +15,8 @@ class Line(Geometry):
1415
Args:
1516
points (List[Point]): A list of `Point` geometries
1617
18+
>>> Line(points = [Point(x=3,y=4), Point(x=3,y=5)])
19+
1720
"""
1821
points: List[Point]
1922

@@ -47,3 +50,12 @@ def draw(self,
4750
False,
4851
color=color,
4952
thickness=thickness)
53+
54+
@validator('points')
55+
def is_geom_valid(cls, points):
56+
if len(points) < 2:
57+
raise ValueError(
58+
f"A line must have at least 2 points to be valid. Found {points}"
59+
)
60+
61+
return points

0 commit comments

Comments
 (0)