MCPcopy Create free account
hub / github.com/Kitware/VTK / vtkVariantStrictWeakOrder

Function vtkVariantStrictWeakOrder

Wrapping/Python/vtkmodules/util/vtkVariant.py:119–153  ·  view source on GitHub ↗

Compare variants by type first, and then by value.

(s1, s2)

Source from the content-addressed store, hash-verified

117
118
119def vtkVariantStrictWeakOrder(s1, s2):
120 """
121 Compare variants by type first, and then by value.
122 """
123 s1 = vtkCommonCore.vtkVariant(s1)
124 s2 = vtkCommonCore.vtkVariant(s2)
125
126 t1 = s1.GetType()
127 t2 = s2.GetType()
128
129 # check based on type
130 if t1 != t2:
131 return t1 < t2
132
133 v1 = s1.IsValid()
134 v2 = s2.IsValid()
135
136 # check based on validity
137 if (not v1) or (not v2):
138 return v1 < v2
139
140 # extract and compare the values
141 r1 = getattr(s1, _variant_method_map[t1])()
142 r2 = getattr(s2, _variant_method_map[t2])()
143
144 # compare vtk objects by classname, then address
145 if t1 == vtkCommonCore.VTK_OBJECT:
146 c1 = r1.GetClassName()
147 c2 = r2.GetClassName()
148 if c1 != c2:
149 return c1 < c2
150 else:
151 return r1.__this__ < r2.__this__
152
153 return r1 < r2
154
155
156class vtkVariantStrictWeakOrderKey:

Callers 2

testComparisonMethodsMethod · 0.90
__lt__Method · 0.85

Calls 4

vtkVariantMethod · 0.80
GetTypeMethod · 0.45
IsValidMethod · 0.45
GetClassNameMethod · 0.45

Tested by 1

testComparisonMethodsMethod · 0.72