Python如何收缩延迟策略

2024-09-28 22:32:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在为Matlab实现PBB,不知何故受到假设的影响

我不明白假设如何处理延迟策略的收缩。 文档中有代码片段

import hypothesis.strategies as st
x = st.deferred(lambda: st.booleans() | st.tuples(x, x))
x.example()
>>> (((False, (True, True)), (False, True)), (True, True))

现在,这个例子很可能通过减少递归的深度来缩小。但是,假设如何知道如何操纵lambda以使示例缩小


马西弗博士回答后的问题:

  • 假设是否存储了哪些选择属于哪种策略?例如:(False,(False,False))可以构造为10010000(深度优先)。如果我们将子序列01(其中第一个0属于策略booleans,而不是现在的tuples),我们将得到示例True,它可能不算作前者的缩小版本

Tags: lambda代码文档importfalsetrue示例策略
1条回答
网友
1楼 · 发布于 2024-09-28 22:32:45

收缩一个延迟的策略与收缩任何其他策略的效果相同,因为在假设中收缩对一个潜在的表示统一起作用,而不需要知道关于所使用的策略的很多信息

假设不是操纵生成的值,而是修改用于构建它们的选择。你可以把这看作是一系列的抛硬币。e、 g.(True, False)可能由序列10100生成,该序列为1(选择|的第二个分支),然后是01,选择第一个分支,然后生成True00,选择第一个分支,然后生成False。我们可以通过用01替换10100(True, False)减少为True,或者通过用00替换False(True, False)减少为True,这两者都可以作为原始选择序列的子序列

如果你想知道更多关于这方面的信息,你可以阅读报纸(或观看演讲):https://2020.ecoop.org/details/ecoop-2020-papers/13/Test-Case-Reduction-via-Test-Case-Generation-Insights-From-the-Hypothesis-Reducer

Is hypothesis storing which choices belong to which strategy? E.g.: (False,(False,False)) can be constructed as 10010000 (depth first). If we take the subsequence 01 (where the first 0 belongs to the strategy booleans instead to tuples now) we would get the example True, which probably does not count as a shrinked version of the former.

不,假设没有任何关于选择的“所有权”的特定概念,并且认为True(False, (False, False))的完全有效的收缩!它毕竟是相当小和简单的

相关问题 更多 >