Skip to content

Commit ab45038

Browse files
authored
Fix Filter Docs (#714)
1 parent 40f7b3b commit ab45038

39 files changed

+388
-16
lines changed

client/valor/schemas/filters.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,47 @@
4141

4242
@dataclass
4343
class Filter:
44+
"""
45+
A data class that encapsulates filter conditions for various Valor components.
46+
47+
Attributes
48+
----------
49+
datasets : dict | FunctionType, optional
50+
Filter conditions to apply to datasets.
51+
models : dict | FunctionType, optional
52+
Filter conditions to apply to models.
53+
datums : dict | FunctionType, optional
54+
Filter conditions to apply to datums.
55+
annotations : dict | FunctionType, optional
56+
Filter conditions to apply to annotations.
57+
groundtruths : dict | FunctionType, optional
58+
Filter conditions to apply to groundtruths.
59+
predictions : dict | FunctionType, optional
60+
Filter conditions to apply to predictions.
61+
labels : dict | FunctionType, optional
62+
Filter conditions to apply to labels.
63+
embeddings : dict | FunctionType, optional
64+
Filter conditions to apply to embeddings.
65+
66+
Examples
67+
--------
68+
Filter annotations by area and label.
69+
>>> Filter(
70+
... annotations=And(
71+
... Label.key == "name",
72+
... Annotation.raster.area > upper_bound,
73+
... )
74+
... )
75+
76+
Filter datums by annotations and labels.
77+
>>> Filter(
78+
... datums=And(
79+
... Label.key == "name",
80+
... Annotation.raster.area > upper_bound,
81+
... )
82+
... )
83+
"""
84+
4485
datasets: Optional[Union[dict, FunctionType]] = None
4586
models: Optional[Union[dict, FunctionType]] = None
4687
datums: Optional[Union[dict, FunctionType]] = None

client/valor/schemas/symbolic/operators.py

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,35 @@ def to_dict(self):
100100

101101

102102
class And(Function):
103-
"""Implementation of logical AND (&)."""
103+
"""
104+
Implementation of logical AND (&).
105+
106+
This class represents a logical AND operation that can be performed on
107+
two or more arguments. It supports chaining of multiple AND operations
108+
using the `&` operator.
109+
110+
Parameters
111+
----------
112+
*args : Any
113+
The arguments to be logically ANDed together. At least two arguments
114+
are required.
115+
116+
Raises
117+
------
118+
ValueError
119+
If fewer than two arguments are provided.
120+
121+
Examples
122+
--------
123+
>>> a = And(Label.key == "k1", Label.value == "v1")
124+
>>> b = And(Label.key == "k1", Label.value == "v2")
125+
>>> c = a & b
126+
127+
Methods
128+
-------
129+
__and__(other)
130+
Supports chaining of multiple `And` operations using the `&` operator.
131+
"""
104132

105133
def __init__(self, *args):
106134
if len(args) < 2:
@@ -116,7 +144,34 @@ def __and__(self, other: Any):
116144

117145

118146
class Or(Function):
119-
"""Implementation of logical OR (|)."""
147+
"""Implementation of logical OR (|).
148+
149+
This class represents a logical OR operation that can be performed on
150+
two or more arguments. It supports chaining of multiple OR operations
151+
using the `|` operator.
152+
153+
Parameters
154+
----------
155+
*args : Any
156+
The arguments to be logically ORed together. At least two arguments
157+
are required.
158+
159+
Raises
160+
------
161+
ValueError
162+
If fewer than two arguments are provided.
163+
164+
Examples
165+
--------
166+
>>> a = Or(Label.key == "k1", Label.key == "k2")
167+
>>> b = Or(Label.value == "v1", Label.value == "v2")
168+
>>> c = a | b
169+
170+
Methods
171+
-------
172+
__or__(other)
173+
Supports chaining of multiple `Or` operations using the `|` operator.
174+
"""
120175

121176
def __init__(self, *args):
122177
if len(args) < 2:
@@ -132,7 +187,33 @@ def __or__(self, other: Any):
132187

133188

134189
class Not(Function):
135-
"""Implementation of logical negation (~)."""
190+
"""Implementation of logical negation (~).
191+
192+
This class represents a logical NOT operation that can be performed on
193+
on a single arguments. It supports chaining of multiple NOT operations
194+
using the `~` operator.
195+
196+
Parameters
197+
----------
198+
*args : Any
199+
The arguments to be logically ORed together. At least two arguments
200+
are required.
201+
202+
Raises
203+
------
204+
ValueError
205+
If the number of args is not equal to one.
206+
207+
Examples
208+
--------
209+
>>> a = Not(Label.key == "k1")
210+
>>> b = ~a
211+
212+
Methods
213+
-------
214+
__invert__()
215+
Supports chaining of multiple `Not` operations using the `~` operator.
216+
"""
136217

137218
def __init__(self, *args):
138219
if len(args) != 1:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.symbolic.operators.Contains
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical

docs/client_api/Schemas/Filters.md renamed to docs/client_api/filtering/Conditions/Gt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
::: valor.schemas.filters
1+
::: valor.schemas.Gt
22
handler: python
33
options:
44
show_root_heading: false
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Gte
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Inside
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Intersects
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.IsNotNull
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.IsNull
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Lt
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Lte
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Ne
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Outside
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical

docs/client_api/filtering/Filter.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Filter
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.And
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Not
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical

docs/client_api/filtering/Logic/Or.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
::: valor.schemas.Or
2+
handler: python
3+
options:
4+
show_root_heading: false
5+
show_root_toc_entry: false
6+
show_root_full_path: true
7+
show_root_members_full_path: false
8+
show_object_full_path: true
9+
show_category_heading: True
10+
show_if_no_docstring: false
11+
show_signature: true
12+
show_signature_annotations: false
13+
show_bases: true
14+
group_by_category: true
15+
heading_level: 2
16+
members_order: alphabetical

0 commit comments

Comments
 (0)