Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
lambda children: st.lists(children) | st.tuples(children) | st.dictionaries(st.binary() | st.text(), children),
max_leaves=100)
b = st.deferred(lambda: st.none() | st.tuples(st.just('b'), a))
lambda e: tuples(integers(0, e - 1), just(e))
)
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"), (
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:
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)
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)
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,
)