Skip to content

Commit cac8d4d

Browse files
committed
add support on all 3
1 parent 855bc88 commit cac8d4d

File tree

4 files changed

+57
-8
lines changed

4 files changed

+57
-8
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
* Changed `compas_ghpython.artists.MeshArtist.draw_vertexlabels` to use the colors of the vertex color dict.
3434
* Changed `compas_ghpython.artists.MeshArtist.draw_edgelabels` to use the colors of the edge color dict.
3535
* Changed `compas_ghpython.artists.MeshArtist.draw_facelabels` to use the colors of the face color dict.
36+
* Changed `compas.datastructures.Graph.nodes_where` to accept conditions as kwargs.
37+
* Changed `compas.datastructures.Graph.edges_where` to accept conditions as kwargs.
38+
* Changed `compas.datastructures.Halfedge.vertices_where` to accept conditions as kwargs.
39+
* Changed `compas.datastructures.Halfedge.edges_where` to accept conditions as kwargs.
40+
* Changed `compas.datastructures.Halfedge.faces_where` to accept conditions as kwargs.
41+
* Changed `compas.datastructures.Halfface.vertices_where` to accept conditions as kwargs.
42+
* Changed `compas.datastructures.Halfface.edges_where` to accept conditions as kwargs.
43+
* Changed `compas.datastructures.Halfface.faces_where` to accept conditions as kwargs.
44+
* Changed `compas.datastructures.Halfface.cells_where` to accept conditions as kwargs.
3645

3746
### Removed
3847

src/compas/datastructures/graph/graph.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def nodes(self, data=False):
622622
else:
623623
yield key, self.node_attributes(key)
624624

625-
def nodes_where(self, conditions, data=False):
625+
def nodes_where(self, conditions, data=False, **kwargs):
626626
"""Get nodes for which a certain condition or set of conditions is true.
627627
628628
Parameters
@@ -641,6 +641,9 @@ def nodes_where(self, conditions, data=False):
641641
If `data` is True, the next node and its attributes.
642642
643643
"""
644+
conditions = conditions or {}
645+
conditions.update(kwargs)
646+
644647
for key, attr in self.nodes(True):
645648
is_match = True
646649

@@ -740,7 +743,7 @@ def edges(self, data=False):
740743
else:
741744
yield u, v
742745

743-
def edges_where(self, conditions, data=False):
746+
def edges_where(self, conditions, data=False, **kwargs):
744747
"""Get edges for which a certain condition or set of conditions is true.
745748
746749
Parameters
@@ -751,6 +754,8 @@ def edges_where(self, conditions, data=False):
751754
values or ranges of attribute values in the form of min/max pairs.
752755
data : bool, optional
753756
If True, yield the edge attributes in addition to the edge identifiers.
757+
**kwargs : dict[str, Any], optional
758+
Additional conditions provided as named function arguments.
754759
755760
Yields
756761
------
@@ -759,6 +764,9 @@ def edges_where(self, conditions, data=False):
759764
If `data` is True, the next edge identifier and its attributes as a ((u, v), attr) tuple.
760765
761766
"""
767+
conditions = conditions or {}
768+
conditions.update(kwargs)
769+
762770
for key in self.edges():
763771
is_match = True
764772

src/compas/datastructures/halfedge/halfedge.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ def vertices_where(self, conditions=None, data=False, **kwargs):
631631
values or ranges of attribute values in the form of min/max pairs.
632632
data : bool, optional
633633
If True, yield the vertex attributes in addition to the vertex identifiers.
634+
**kwargs : dict[str, Any], optional
635+
Additional conditions provided as named function arguments.
634636
635637
Yields
636638
------
@@ -724,7 +726,7 @@ def vertices_where_predicate(self, predicate, data=False):
724726
else:
725727
yield key
726728

727-
def edges_where(self, conditions, data=False):
729+
def edges_where(self, conditions, data=False, **kwargs):
728730
"""Get edges for which a certain condition or set of conditions is true.
729731
730732
Parameters
@@ -735,6 +737,8 @@ def edges_where(self, conditions, data=False):
735737
values or ranges of attribute values in the form of min/max pairs.
736738
data : bool, optional
737739
If True, yield the edge attributes in addition to the edge identifiers.
740+
**kwargs : dict[str, Any], optional
741+
Additional conditions provided as named function arguments.
738742
739743
Yields
740744
------
@@ -743,6 +747,9 @@ def edges_where(self, conditions, data=False):
743747
If `data` is True, the next edge as a (u, v, data) tuple.
744748
745749
"""
750+
conditions = conditions or {}
751+
conditions.update(kwargs)
752+
746753
for key in self.edges():
747754
is_match = True
748755

@@ -806,7 +813,7 @@ def edges_where_predicate(self, predicate, data=False):
806813
else:
807814
yield key
808815

809-
def faces_where(self, conditions, data=False):
816+
def faces_where(self, conditions, data=False, **kwargs):
810817
"""Get faces for which a certain condition or set of conditions is true.
811818
812819
Parameters
@@ -817,6 +824,8 @@ def faces_where(self, conditions, data=False):
817824
values or ranges of attribute values in the form of min/max pairs.
818825
data : bool, optional
819826
If True, yield the face attributes in addition to face identifiers.
827+
**kwargs : dict[str, Any], optional
828+
Additional conditions provided as named function arguments.
820829
821830
Yields
822831
------
@@ -825,6 +834,9 @@ def faces_where(self, conditions, data=False):
825834
If `data` is True, the next face and its attributes.
826835
827836
"""
837+
conditions = conditions or {}
838+
conditions.update(kwargs)
839+
828840
for fkey in self.faces():
829841
is_match = True
830842

src/compas/datastructures/halfface/halfface.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def cells(self, data=False):
715715
else:
716716
yield cell, self.cell_attributes(cell)
717717

718-
def vertices_where(self, conditions, data=False):
718+
def vertices_where(self, conditions, data=False, **kwargs):
719719
"""Get vertices for which a certain condition or set of conditions is true.
720720
721721
Parameters
@@ -726,6 +726,8 @@ def vertices_where(self, conditions, data=False):
726726
values or ranges of attribute values in the form of min/max pairs.
727727
data : bool, optional
728728
If True, yield the vertex attributes in addition to the identifiers.
729+
**kwargs : dict[str, Any], optional
730+
Additional conditions provided as named function arguments.
729731
730732
Yields
731733
------
@@ -734,6 +736,9 @@ def vertices_where(self, conditions, data=False):
734736
If `data` is True, the next vertex and its attributes.
735737
736738
"""
739+
conditions = conditions or {}
740+
conditions.update(kwargs)
741+
737742
for key, attr in self.vertices(True):
738743
is_match = True
739744

@@ -811,7 +816,7 @@ def vertices_where_predicate(self, predicate, data=False):
811816
else:
812817
yield key
813818

814-
def edges_where(self, conditions, data=False):
819+
def edges_where(self, conditions, data=False, **kwargs):
815820
"""Get edges for which a certain condition or set of conditions is true.
816821
817822
Parameters
@@ -822,6 +827,8 @@ def edges_where(self, conditions, data=False):
822827
values or ranges of attribute values in the form of min/max pairs.
823828
data : bool, optional
824829
If True, yield the edge attributes in addition to the identifiers.
830+
**kwargs : dict[str, Any], optional
831+
Additional conditions provided as named function arguments.
825832
826833
Yields
827834
------
@@ -830,6 +837,9 @@ def edges_where(self, conditions, data=False):
830837
If `data` is True, the next edge as a (u, v, data) tuple.
831838
832839
"""
840+
conditions = conditions or {}
841+
conditions.update(kwargs)
842+
833843
for key in self.edges():
834844
is_match = True
835845

@@ -891,7 +901,7 @@ def edges_where_predicate(self, predicate, data=False):
891901
else:
892902
yield key
893903

894-
def faces_where(self, conditions, data=False):
904+
def faces_where(self, conditions, data=False, **kwargs):
895905
"""Get faces for which a certain condition or set of conditions is true.
896906
897907
Parameters
@@ -902,6 +912,8 @@ def faces_where(self, conditions, data=False):
902912
values or ranges of attribute values in the form of min/max pairs.
903913
data : bool, optional
904914
If True, yield the face attributes in addition to the identifiers.
915+
**kwargs : dict[str, Any], optional
916+
Additional conditions provided as named function arguments.
905917
906918
Yields
907919
------
@@ -910,6 +922,9 @@ def faces_where(self, conditions, data=False):
910922
If `data` is True, the next face and its attributes.
911923
912924
"""
925+
conditions = conditions or {}
926+
conditions.update(kwargs)
927+
913928
for fkey in self.faces():
914929
is_match = True
915930

@@ -971,7 +986,7 @@ def faces_where_predicate(self, predicate, data=False):
971986
else:
972987
yield fkey
973988

974-
def cells_where(self, conditions, data=False):
989+
def cells_where(self, conditions, data=False, **kwargs):
975990
"""Get cells for which a certain condition or set of conditions is true.
976991
977992
Parameters
@@ -982,6 +997,8 @@ def cells_where(self, conditions, data=False):
982997
values or ranges of attribute values in the form of min/max pairs.
983998
data : bool, optional
984999
If True, yield the cell attributes in addition to the identifiers.
1000+
**kwargs : dict[str, Any], optional
1001+
Additional conditions provided as named function arguments.
9851002
9861003
Yields
9871004
------
@@ -990,6 +1007,9 @@ def cells_where(self, conditions, data=False):
9901007
If `data` is True, the next cell and its attributes.
9911008
9921009
"""
1010+
conditions = conditions or {}
1011+
conditions.update(kwargs)
1012+
9931013
for ckey in self.cells():
9941014
is_match = True
9951015

0 commit comments

Comments
 (0)