How to use the hypothesis.strategies.tuples function in hypothesis

To help you get started, we’ve selected a few hypothesis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rsokl / MyGrad / tests / tensor_ops / test_sequence_ops.py View on Github external
def test_sequential_arithmetic(
    sequential_function: Tuple[Callable, Callable],
    shapes: hnp.BroadcastableShapes,
    data: st.DataObject,
):
    mygrad_func, true_func = sequential_function
    tensors = data.draw(
        st.tuples(
            *(
                hnp.arrays(
                    shape=shape, dtype=np.float32, elements=st.floats(-10, 10, width=32)
                ).map(Tensor)
                for shape in shapes.input_shapes
            )
        ),
        label="tensors",
    )

    tensors_copy = [x.copy() for x in tensors]

    f = mygrad_func(*tensors)
    f1 = true_func(tensors_copy)

    assert_allclose(f.data, f1.data)
github akesterson / dpath-python / tests / test_segments.py View on Github external
        lambda children: st.lists(children) | st.tuples(children) | st.dictionaries(st.binary() | st.text(), children),
        max_leaves=100)
github HypothesisWorks / hypothesis / tests / cover / test_deferred_strategies.py View on Github external
    b = st.deferred(lambda: st.none() | st.tuples(st.just('b'), a))
github datawire / mdk / unittests / test_discovery.py View on Github external
def get_address(service_name):
            return st.tuples(st.just(service_name), st.sampled_from(
                self.fake.services[service_name]))
        return st.tuples(st.just("remove"), (
github ethereum / py-trie / tests / test_hexary_trie.py View on Github external
minimum_insert_value_length = draw(st.integers(min_value=3, max_value=32))

    latest_keys = list(start_keys)
    inserts = [
        (key, key.ljust(minimum_insert_value_length, b'3'))
        for key in start_keys
    ]
    updates = []

    for _ in range(max_size):
        # Select the next change
        if len(latest_keys):
            next_change = draw(st.one_of(
                # insert
                st.tuples(
                    st.binary(min_size=3, max_size=3),
                ),
                # update
                st.tuples(
                    st.sampled_from(latest_keys),
                    st.binary(min_size=1, max_size=128),
                ),
                # delete
                st.tuples(
                    st.sampled_from(latest_keys),
                    # Sometimes run deletes as sets, sometimes as deletes.
                    # Test code should call `del trie[key]` if value is None
                    st.one_of(st.none(), st.just(b'')),
                )
            ))
        else:
github mapbox / rio-pansharpen / tests / test_property_based.py View on Github external
    st.tuples(st.integers(min_value=2), st.integers(min_value=2)))
def test_make_affine(fr_shape, to_shape):
    fr_affine, to_affine = _make_affine(fr_shape, to_shape)
    assert to_affine[4] == -(fr_shape[0] / float(to_shape[0]))
    assert fr_affine[2] == float(0) and to_affine[2] == float(0)
    assert fr_affine[0] == float(1) and fr_affine[4] == -float(1)
github fabiommendes / sidekick / sidekick / hypothesis / base.py View on Github external
def kwargs(values=atoms(), **kwargs):
    """
    Create dictionaries that represent valid keyword arguments.
    """
    names = identifiers(**kwargs)
    pairs = st.tuples(names, values)
    return st.lists(pairs).map(dict)
github ethereum / py-trie / trie / tools / strategies.py View on Github external
def build_up_from_children(children):
        # Branch out
        return st.tuples(
            st.binary(min_size=0, max_size=3),
            children,
            st.binary(min_size=0, max_size=3),
            children,
        )