本文整理汇总了Python中autocompleter.Autocompleter.hash_facets方法的典型用法代码示例。如果您正苦于以下问题:Python Autocompleter.hash_facets方法的具体用法?Python Autocompleter.hash_facets怎么用?Python Autocompleter.hash_facets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autocompleter.Autocompleter
的用法示例。
在下文中一共展示了Autocompleter.hash_facets方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hash_identical_values_different_facet_type
# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import hash_facets [as 别名]
def test_hash_identical_values_different_facet_type(self):
"""
Facets with same key/values but different facet type in different order shouldn't have same hash
"""
facet_1 = [
{
'type': 'and',
'facets': [
{'key': 'sector', 'value': 'Technology'},
{'key': 'industry', 'value': 'Software'}
]
}
]
facet_2 = [
{
'type': 'or',
'facets': [
{'key': 'industry', 'value': 'Software'},
{'key': 'sector', 'value': 'Technology'}
]
}
]
facet_1_hash = Autocompleter.hash_facets(facet_1)
facet_2_hash = Autocompleter.hash_facets(facet_2)
self.assertNotEqual(facet_1_hash, facet_2_hash)
示例2: test_hashing_order
# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import hash_facets [as 别名]
def test_hashing_order(self):
"""
Facets with identical key/values in different order should still have same hash
"""
facet_1 = [
{
'type': 'or',
'facets': [
{'key': 'sector', 'value': 'Technology'},
{'key': 'industry', 'value': 'Software'}
]
}
]
facet_2 = [
{
'type': 'or',
'facets': [
{'key': 'industry', 'value': 'Software'},
{'key': 'sector', 'value': 'Technology'}
]
}
]
facet_1_hash = Autocompleter.hash_facets(facet_1)
facet_2_hash = Autocompleter.hash_facets(facet_2)
self.assertEqual(facet_1_hash, facet_2_hash)
示例3: test_facet_identity_hash
# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import hash_facets [as 别名]
def test_facet_identity_hash(self):
"""
Hashing a facet should equal the hash of an earlier call
"""
facets = [
{
'type': 'or',
'facets': [{'key': 'sector', 'value': 'Technology'}]
}
]
first_hash = Autocompleter.hash_facets(facets)
second_hash = Autocompleter.hash_facets(facets)
self.assertEqual(first_hash, second_hash)
示例4: test_hashing_facet_type
# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import hash_facets [as 别名]
def test_hashing_facet_type(self):
"""
Facet list with same sub facets but different type should not have equal hashes
"""
and_facet = [
{
'type': 'and',
'facets': [{'key': 'sector', 'value': 'Technology'}]
}
]
or_facet = [
{
'type': 'or',
'facets': [{'key': 'sector', 'value': 'Technology'}]
}
]
and_hash = Autocompleter.hash_facets(and_facet)
or_hash = Autocompleter.hash_facets(or_facet)
self.assertNotEqual(and_hash, or_hash)
示例5: test_multiple_facets_hashing_order
# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import hash_facets [as 别名]
def test_multiple_facets_hashing_order(self):
"""
A facet list with multiple facets should have same hash when key/values are identical regardless of order
"""
facet_1 = [
{
'type': 'or',
'facets': [
{'key': 'sector', 'value': 'Technology'},
{'key': 'industry', 'value': 'Software'}
]
},
{
'type': 'and',
'facets': [
{'key': 'sector', 'value': 'Energy'},
{'key': 'industry', 'value': 'Oil & Gas Integrated'}
]
}
]
facet_2 = [
{
'type': 'and',
'facets': [
{'key': 'industry', 'value': 'Oil & Gas Integrated'},
{'key': 'sector', 'value': 'Energy'}
]
},
{
'type': 'or',
'facets': [
{'key': 'sector', 'value': 'Technology'},
{'key': 'industry', 'value': 'Software'}
]
},
]
facet_1_hash = Autocompleter.hash_facets(facet_1)
facet_2_hash = Autocompleter.hash_facets(facet_2)
self.assertEqual(facet_1_hash, facet_2_hash)