Testing helpers#
- ivy_tests.test_ivy.helpers.testing_helpers.handle_frontend_method(*, class_tree, init_tree, method_name, init_num_positional_args=None, init_native_arrays=lists(booleans(), min_size=1, max_size=1), init_as_variable_flags=_as_varaible_strategy(), method_num_positional_args=None, method_native_arrays=lists(booleans(), min_size=1, max_size=1), method_as_variable_flags=_as_varaible_strategy(), **_given_kwargs)[source]#
Test wrapper for Ivy frontends methods.
The wrapper sets the required test globals and creates test flags strategies.
- Parameters:
class_tree (
str
) – Full class import pathinit_tree (
str
) – Full import path for the function used to create the classmethod_name (
str
) – Name of the method
- ivy_tests.test_ivy.helpers.testing_helpers.handle_frontend_test(*, fn_tree, aliases=None, number_positional_args=None, test_with_out=booleans(), test_inplace=just(False), as_variable_flags=_as_varaible_strategy(), native_array_flags=lists(booleans(), min_size=1, max_size=1), generate_frontend_arrays=booleans(), **_given_kwargs)[source]#
Test wrapper for Ivy frontend functions.
The wrapper sets the required test globals and creates test flags strategies.
- Parameters:
fn_tree (
str
) – Full function import pathnumber_positional_args – A search strategy for determining the number of positional arguments to be passed to the function
test_inplace – A search strategy that generates a boolean to test the method with inplace update
test_with_out – A search strategy that generates a boolean to test the function with an out parameter
as_variable_flags – A search strategy that generates a list of boolean flags for array inputs to be passed as a Variable array
native_array_flags – A search strategy that generates a list of boolean flags for array inputs to be passed as a native array
generate_frontend_arrays – A search strategy that generates a list of boolean flags for array inputs to be frontend array
- ivy_tests.test_ivy.helpers.testing_helpers.handle_method(*, method_tree=None, ground_truth_backend='tensorflow', test_gradients=_gradient_strategy(), test_compile=_compile_strategy(), init_num_positional_args=None, init_native_arrays=lists(booleans(), min_size=1, max_size=1), init_as_variable_flags=_as_varaible_strategy(), method_num_positional_args=None, method_native_arrays=lists(booleans(), min_size=1, max_size=1), method_as_variable_flags=_as_varaible_strategy(), method_container_flags=lists(booleans(), min_size=1, max_size=1), **_given_kwargs)[source]#
Test wrapper for Ivy methods.
The wrapper sets the required test globals and creates test flags strategies.
- Parameters:
method_tree (
Optional
[str
]) – Full method import path (default:None
)ground_truth_backend (
str
) – The framework to assert test results are equal to (default:'tensorflow'
)
- ivy_tests.test_ivy.helpers.testing_helpers.handle_test(*, fn_tree=None, ground_truth_backend='tensorflow', number_positional_args=None, test_instance_method=booleans(), test_with_out=booleans(), test_gradients=_gradient_strategy(), test_compile=_compile_strategy(), as_variable_flags=_as_varaible_strategy(), native_array_flags=lists(booleans(), min_size=1, max_size=1), container_flags=lists(booleans(), min_size=1, max_size=1), **_given_kwargs)[source]#
Test wrapper for Ivy functions.
The wrapper sets the required test globals and creates test flags strategies.
- Parameters:
fn_tree (
Optional
[str
]) – Full function import path (default:None
)ground_truth_backend (
str
) – The framework to assert test results are equal to (default:'tensorflow'
)number_positional_args – A search strategy for determining the number of positional arguments to be passed to the function
test_instance_method – A search strategy that generates a boolean to test instance methods
test_with_out – A search strategy that generates a boolean to test the function with an out parameter
test_gradients – A search strategy that generates a boolean to test the function with arrays as gradients
test_compile – A search strategy that generates a boolean to graph compile and test the function
as_variable_flags – A search strategy that generates a list of boolean flags for array inputs to be passed as a Variable array
native_array_flags – A search strategy that generates a list of boolean flags for array inputs to be passed as a native array
container_flags – A search strategy that generates a list of boolean flags for array inputs to be passed as a Container
- ivy_tests.test_ivy.helpers.testing_helpers.num_positional_args(*, fn_name=None)[source]#
Draws an integers randomly from the minimum and maximum number of positional arguments a given function can take.
- Parameters:
draw – special function that draws data randomly (but is reproducible) from a given data-set (ex. list).
fn_name (
Optional
[str
]) – name of the function. (default:None
)
- Return type:
SearchStrategy
- Returns:
A strategy that can be used in the @given hypothesis decorator.
Examples
- @given(
num_positional_args=num_positional_args(fn_name=”floor_divide”)
) @given(
num_positional_args=num_positional_args(fn_name=”add”)
)
- ivy_tests.test_ivy.helpers.testing_helpers.num_positional_args_method(*, method)[source]#
Draws an integers randomly from the minimum and maximum number of positional arguments a given method can take.
- Parameters:
draw – special function that draws data randomly (but is reproducible) from a given data-set (ex. list).
method – callable method
- Return type:
SearchStrategy
- Returns:
A strategy that can be used in the @given hypothesis decorator.