Skip to content

Commit 855bc88

Browse files
committed
allow for kwargs
1 parent 8ef4acc commit 855bc88

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

src/compas/datastructures/halfedge/halfedge.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ def edges(self, data=False):
620620
else:
621621
yield key, self.edge_attributes(key)
622622

623-
def vertices_where(self, conditions, data=False):
623+
def vertices_where(self, conditions=None, data=False, **kwargs):
624624
"""Get vertices for which a certain condition or set of conditions is true.
625625
626626
Parameters
@@ -639,6 +639,9 @@ def vertices_where(self, conditions, data=False):
639639
If `data` is True, the next vertex and its attributes.
640640
641641
"""
642+
conditions = conditions or {}
643+
conditions.update(kwargs)
644+
642645
for key, attr in self.vertices(True):
643646
is_match = True
644647

src/compas/datastructures/halfface/halfface.py

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,7 @@ def vertices_where(self, conditions, data=False):
725725
The keys should be attribute names. The values can be attribute
726726
values or ranges of attribute values in the form of min/max pairs.
727727
data : bool, optional
728-
Yield the vertices and their data attributes.
729-
Default is ``False``.
728+
If True, yield the vertex attributes in addition to the identifiers.
730729
731730
Yields
732731
------
@@ -793,11 +792,10 @@ def vertices_where_predicate(self, predicate, data=False):
793792
Parameters
794793
----------
795794
predicate : callable
796-
The condition you want to evaluate. The callable takes 2 parameters:
797-
``key``, ``attr`` and should return ``True`` or ``False``.
795+
The condition you want to evaluate.
796+
The callable takes 2 parameters: the vertex identifier and the vertex attributes, and should return True or False.
798797
data : bool, optional
799-
Yield the vertices and their data attributes.
800-
Default is ``False``.
798+
If True, yield the vertex attributes in addition to the identifiers.
801799
802800
Yields
803801
------
@@ -823,8 +821,7 @@ def edges_where(self, conditions, data=False):
823821
The keys should be attribute names. The values can be attribute
824822
values or ranges of attribute values in the form of min/max pairs.
825823
data : bool, optional
826-
Yield the edges and their data attributes.
827-
Default is ``False``.
824+
If True, yield the edge attributes in addition to the identifiers.
828825
829826
Yields
830827
------
@@ -875,11 +872,10 @@ def edges_where_predicate(self, predicate, data=False):
875872
Parameters
876873
----------
877874
predicate : callable
878-
The condition you want to evaluate. The callable takes 3 parameters:
879-
``u``, ``v``, ``attr`` and should return ``True`` or ``False``.
875+
The condition you want to evaluate.
876+
The callable takes 2 parameters: the edge identifier and the edge attributes, and should return True or False.
880877
data : bool, optional
881-
Yield the vertices and their data attributes.
882-
Default is ``False``.
878+
If True, yield the edge attributes in addition to the identifiers.
883879
884880
Yields
885881
------
@@ -905,8 +901,7 @@ def faces_where(self, conditions, data=False):
905901
The keys should be attribute names. The values can be attribute
906902
values or ranges of attribute values in the form of min/max pairs.
907903
data : bool, optional
908-
Yield the faces and their data attributes.
909-
Default is ``False``.
904+
If True, yield the face attributes in addition to the identifiers.
910905
911906
Yields
912907
------
@@ -957,11 +952,10 @@ def faces_where_predicate(self, predicate, data=False):
957952
Parameters
958953
----------
959954
predicate : callable
960-
The condition you want to evaluate. The callable takes 2 parameters:
961-
``key``, ``attr`` and should return ``True`` or ``False``.
955+
The condition you want to evaluate.
956+
The callable takes 2 parameters: the face identifier and the the face attributes, and should return True or False.
962957
data : bool, optional
963-
Yield the faces and their data attributes.
964-
Default is ``False``.
958+
If True, yield the face attributes in addition to the identifiers.
965959
966960
Yields
967961
------
@@ -987,8 +981,7 @@ def cells_where(self, conditions, data=False):
987981
The keys should be attribute names. The values can be attribute
988982
values or ranges of attribute values in the form of min/max pairs.
989983
data : bool, optional
990-
Yield the cells and their data attributes.
991-
Default is ``False``.
984+
If True, yield the cell attributes in addition to the identifiers.
992985
993986
Yields
994987
------
@@ -1039,11 +1032,10 @@ def cells_where_predicate(self, predicate, data=False):
10391032
Parameters
10401033
----------
10411034
predicate : callable
1042-
The condition you want to evaluate. The callable takes 2 parameters:
1043-
``key``, ``attr`` and should return ``True`` or ``False``.
1035+
The condition you want to evaluate.
1036+
The callable takes 2 parameters: the cell identifier and the cell attributes, and should return True or False.
10441037
data : bool, optional
1045-
Yield the cells and their data attributes.
1046-
Default is ``False``.
1038+
If True, yield the cell attributes in addition to the identifiers.
10471039
10481040
Yields
10491041
------

0 commit comments

Comments
 (0)