当前位置: 首页>>代码示例>>Python>>正文


Python Autocompleter.hash_facets方法代码示例

本文整理汇总了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)
开发者ID:ycharts,项目名称:django-autocompleter,代码行数:29,代码来源:test_utils.py

示例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)
开发者ID:ycharts,项目名称:django-autocompleter,代码行数:29,代码来源:test_utils.py

示例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)
开发者ID:ycharts,项目名称:django-autocompleter,代码行数:15,代码来源:test_utils.py

示例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)
开发者ID:ycharts,项目名称:django-autocompleter,代码行数:22,代码来源:test_utils.py

示例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)
开发者ID:ycharts,项目名称:django-autocompleter,代码行数:43,代码来源:test_utils.py


注:本文中的autocompleter.Autocompleter.hash_facets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。