class documentation

class TestUfunc: (source)

View In Hierarchy

Undocumented

Method check_identityless_reduction Undocumented
Method compare_matrix_multiply_results Undocumented
Method test_all_ufunc Try to check presence and results of all ufuncs.
Method test_at_not_none_signature Undocumented
Method test_axes_argument Undocumented
Method test_axis_argument Undocumented
Method test_axis_out_of_bounds Undocumented
Method test_broadcast Undocumented
Method test_can_ignore_signature Undocumented
Method test_cast_safety Basic test for the safest casts, because ufuncs inner loops can indicate a cast-safety as well (which is normally always "no").
Method test_casting_out_param Undocumented
Method test_cross1d Test with fixed-sized signature.
Method test_cumsum Undocumented
Method test_custom_array_like Undocumented
Method test_custom_ufunc Undocumented
Method test_custom_ufunc_forced_sig Undocumented
Method test_endian Undocumented
Method test_euclidean_pdist Undocumented
Method test_forced_dtype_times Undocumented
Method test_forced_sig Undocumented
Method test_get_signature Undocumented
Method test_identityless_reduction_corder Undocumented
Method test_identityless_reduction_forder Undocumented
Method test_identityless_reduction_huge_array Undocumented
Method test_identityless_reduction_noncontig Undocumented
Method test_identityless_reduction_noncontig_unaligned Undocumented
Method test_identityless_reduction_nonreorderable Undocumented
Method test_identityless_reduction_otherorder Undocumented
Method test_incontiguous_array Undocumented
Method test_initial_reduction Undocumented
Method test_inner1d Undocumented
Method test_innerwt Undocumented
Method test_innerwt_empty Test generalized ufunc with zero-sized operands
Method test_inplace_fancy_indexing Undocumented
Method test_invalid_args Undocumented
Method test_keepdims_argument Undocumented
Method test_logical_ufuncs_mixed_object_signatures Undocumented
Method test_logical_ufuncs_object_signatures Undocumented
Method test_logical_ufuncs_out_cast_check Undocumented
Method test_logical_ufuncs_reject_string Logical ufuncs are normally well defined by working with the boolean equivalent, i.e. casting all inputs to bools should work.
Method test_logical_ufuncs_support_anything Undocumented
Method test_matrix_multiply Undocumented
Method test_matrix_multiply_umath_empty Undocumented
Method test_nat_is_nan Undocumented
Method test_nat_is_not_finite Undocumented
Method test_nat_is_not_inf Undocumented
Method test_no_doc_string Undocumented
Method test_NotImplemented_not_returned Undocumented
Method test_object_array_accumulate_failure Undocumented
Method test_object_array_accumulate_inplace Undocumented
Method test_object_array_reduceat_failure Undocumented
Method test_object_array_reduceat_inplace Undocumented
Method test_object_array_reduction Undocumented
Method test_object_comparison Undocumented
Method test_object_logical Undocumented
Method test_operand_flags Undocumented
Method test_out_broadcast_errors Undocumented
Method test_out_broadcasts Undocumented
Method test_output_argument Undocumented
Method test_partial_signature_mismatch Undocumented
Method test_partial_signature_mismatch_with_cache Undocumented
Method test_pickle Undocumented
Method test_pickle_name_is_qualname Undocumented
Method test_pickle_withstring Undocumented
Method test_reduce_arguments Undocumented
Method test_reduce_noncontig_output Undocumented
Method test_reduce_output_does_not_broadcast_input Undocumented
Method test_reduce_output_subclass_ok Undocumented
Method test_reduce_wrong_dimension_output Undocumented
Method test_reduce_zero_axis Undocumented
Method test_reduceat_and_accumulate_out_shape_mismatch Undocumented
Method test_reduceat_shifting_sum Undocumented
Method test_reducelike_byteorder_resolution Undocumented
Method test_reducelike_out_promotes Undocumented
Method test_reducelike_output_needs_identical_cast Undocumented
Method test_reduction_where_initial_needed Undocumented
Method test_reduction_with_where Undocumented
Method test_reduction_with_where_and_initial Undocumented
Method test_safe_casting Undocumented
Method test_scalar_equal Undocumented
Method test_scalar_reduction Undocumented
Method test_signature0 Undocumented
Method test_signature1 Undocumented
Method test_signature10 Undocumented
Method test_signature2 Undocumented
Method test_signature3 Undocumented
Method test_signature4 Undocumented
Method test_signature5 Undocumented
Method test_signature6 Undocumented
Method test_signature7 Undocumented
Method test_signature8 Undocumented
Method test_signature9 Undocumented
Method test_signature_all_None Undocumented
Method test_signature_dtype_instances_allowed Undocumented
Method test_signature_dtype_type Undocumented
Method test_signature_errors Undocumented
Method test_signature_failure_extra_parenthesis Undocumented
Method test_signature_failure_mismatching_parenthesis Undocumented
Method test_signature_failure_signature_missing_input_arg Undocumented
Method test_signature_failure_signature_missing_output_arg Undocumented
Method test_struct_ufunc Undocumented
Method test_structured_equal Undocumented
Method test_sum Undocumented
Method test_sum_complex Undocumented
Method test_sum_initial Undocumented
Method test_sum_stability Undocumented
Method test_sum_where Undocumented
Method test_true_divide Undocumented
Method test_type_cast Undocumented
Method test_ufunc_custom_out Undocumented
Method test_use_output_signature_for_all_arguments Undocumented
Method test_where_param Undocumented
Method test_where_param_alloc Undocumented
Method test_where_param_buffer_output Undocumented
Method test_where_with_broadcasting Undocumented
Method test_zerosize_reduction Undocumented
Class Variable can_ignore Undocumented
Class Variable size_inferred Undocumented
def check_identityless_reduction(self, a): (source)

Undocumented

def compare_matrix_multiply_results(self, tp): (source)

Undocumented

def test_all_ufunc(self): (source)

Try to check presence and results of all ufuncs. The list of ufuncs comes from generate_umath.py and is as follows: ===== ==== ============= =============== ======================== done args function types notes ===== ==== ============= =============== ======================== n 1 conjugate nums + O n 1 absolute nums + O complex -> real n 1 negative nums + O n 1 sign nums + O -> int n 1 invert bool + ints + O flts raise an error n 1 degrees real + M cmplx raise an error n 1 radians real + M cmplx raise an error n 1 arccos flts + M n 1 arccosh flts + M n 1 arcsin flts + M n 1 arcsinh flts + M n 1 arctan flts + M n 1 arctanh flts + M n 1 cos flts + M n 1 sin flts + M n 1 tan flts + M n 1 cosh flts + M n 1 sinh flts + M n 1 tanh flts + M n 1 exp flts + M n 1 expm1 flts + M n 1 log flts + M n 1 log10 flts + M n 1 log1p flts + M n 1 sqrt flts + M real x < 0 raises error n 1 ceil real + M n 1 trunc real + M n 1 floor real + M n 1 fabs real + M n 1 rint flts + M n 1 isnan flts -> bool n 1 isinf flts -> bool n 1 isfinite flts -> bool n 1 signbit real -> bool n 1 modf real -> (frac, int) n 1 logical_not bool + nums + M -> bool n 2 left_shift ints + O flts raise an error n 2 right_shift ints + O flts raise an error n 2 add bool + nums + O boolean + is || n 2 subtract bool + nums + O boolean - is ^ n 2 multiply bool + nums + O boolean * is & n 2 divide nums + O n 2 floor_divide nums + O n 2 true_divide nums + O bBhH -> f, iIlLqQ -> d n 2 fmod nums + M n 2 power nums + O n 2 greater bool + nums + O -> bool n 2 greater_equal bool + nums + O -> bool n 2 less bool + nums + O -> bool n 2 less_equal bool + nums + O -> bool n 2 equal bool + nums + O -> bool n 2 not_equal bool + nums + O -> bool n 2 logical_and bool + nums + M -> bool n 2 logical_or bool + nums + M -> bool n 2 logical_xor bool + nums + M -> bool n 2 maximum bool + nums + O n 2 minimum bool + nums + O n 2 bitwise_and bool + ints + O flts raise an error n 2 bitwise_or bool + ints + O flts raise an error n 2 bitwise_xor bool + ints + O flts raise an error n 2 arctan2 real + M n 2 remainder ints + real + O n 2 hypot real + M ===== ==== ============= =============== ======================== Types other than those listed will be accepted, but they are cast to the smallest compatible type for which the function is defined. The casting rules are: bool -> int8 -> float32 ints -> double

def test_at_not_none_signature(self): (source)

Undocumented

def test_axes_argument(self): (source)

Undocumented

def test_axis_argument(self): (source)

Undocumented

def test_axis_out_of_bounds(self): (source)

Undocumented

def test_broadcast(self): (source)

Undocumented

def test_can_ignore_signature(self): (source)

Undocumented

@pytest.mark.parametrize('ufunc', [np.add, np.sqrt])
def test_cast_safety(self, ufunc): (source)

Basic test for the safest casts, because ufuncs inner loops can indicate a cast-safety as well (which is normally always "no").

def test_casting_out_param(self): (source)

Undocumented

def test_cross1d(self): (source)

Test with fixed-sized signature.

def test_cumsum(self): (source)

Undocumented

def test_custom_array_like(self): (source)

Undocumented

def test_custom_ufunc(self): (source)

Undocumented

def test_custom_ufunc_forced_sig(self): (source)

Undocumented

def test_endian(self): (source)

Undocumented

def test_euclidean_pdist(self): (source)

Undocumented

def test_forced_dtype_times(self): (source)

Undocumented

def test_forced_sig(self): (source)

Undocumented

def test_get_signature(self): (source)

Undocumented

def test_identityless_reduction_corder(self): (source)

Undocumented

def test_identityless_reduction_forder(self): (source)

Undocumented

@requires_memory(6*1024**3)
def test_identityless_reduction_huge_array(self): (source)

Undocumented

def test_identityless_reduction_noncontig(self): (source)

Undocumented

def test_identityless_reduction_noncontig_unaligned(self): (source)

Undocumented

def test_identityless_reduction_nonreorderable(self): (source)

Undocumented

def test_identityless_reduction_otherorder(self): (source)

Undocumented

def test_incontiguous_array(self): (source)

Undocumented

def test_initial_reduction(self): (source)

Undocumented

def test_inner1d(self): (source)

Undocumented

def test_innerwt(self): (source)

Undocumented

def test_innerwt_empty(self): (source)

Test generalized ufunc with zero-sized operands

def test_inplace_fancy_indexing(self): (source)

Undocumented

def test_invalid_args(self): (source)

Undocumented

def test_keepdims_argument(self): (source)

Undocumented

@pytest.mark.parametrize('ufunc', [np.logical_and, np.logical_or, np.logical_xor])
@pytest.mark.parametrize('signature', [(bool, None, object), (object, None, bool), (None, object, bool)])
def test_logical_ufuncs_mixed_object_signatures(self, ufunc, signature): (source)

Undocumented

@pytest.mark.parametrize('ufunc', [np.logical_and, np.logical_or])
@pytest.mark.parametrize('signature', [(None, None, object), (object, None, None), (None, object, None)])
def test_logical_ufuncs_object_signatures(self, ufunc, signature): (source)

Undocumented

@pytest.mark.parametrize('ufunc', [np.logical_and, np.logical_or, np.logical_xor])
def test_logical_ufuncs_out_cast_check(self, ufunc): (source)

Undocumented

@pytest.mark.parametrize('ufunc', [np.logical_and, np.logical_or, np.logical_xor])
def test_logical_ufuncs_reject_string(self, ufunc): (source)

Logical ufuncs are normally well defined by working with the boolean equivalent, i.e. casting all inputs to bools should work.

However, casting strings to bools is currently weird, because it actually uses bool(int(str)). Thus we explicitly reject strings. This test should succeed (and can probably just be removed) as soon as string to bool casts are well defined in NumPy.

@pytest.mark.parametrize('ufunc', [np.logical_and, np.logical_or, np.logical_xor])
def test_logical_ufuncs_support_anything(self, ufunc): (source)

Undocumented

def test_matrix_multiply(self): (source)

Undocumented

def test_matrix_multiply_umath_empty(self): (source)

Undocumented

@pytest.mark.parametrize('nat', [np.datetime64('nat'), np.timedelta64('nat')])
def test_nat_is_nan(self, nat): (source)

Undocumented

@pytest.mark.parametrize('nat', [np.datetime64('nat'), np.timedelta64('nat')])
def test_nat_is_not_finite(self, nat): (source)

Undocumented

@pytest.mark.parametrize('nat', [np.datetime64('nat'), np.timedelta64('nat')])
def test_nat_is_not_inf(self, nat): (source)

Undocumented

def test_no_doc_string(self): (source)

Undocumented

def test_NotImplemented_not_returned(self): (source)

Undocumented

def test_object_array_accumulate_failure(self): (source)

Undocumented

def test_object_array_accumulate_inplace(self): (source)

Undocumented

def test_object_array_reduceat_failure(self): (source)

Undocumented

def test_object_array_reduceat_inplace(self): (source)

Undocumented

def test_object_array_reduction(self): (source)

Undocumented

def test_object_comparison(self): (source)

Undocumented

def test_object_logical(self): (source)

Undocumented

def test_operand_flags(self): (source)

Undocumented

@pytest.mark.parametrize(['arr', 'out'], [([2], np.empty(())), ([1, 2], np.empty(1)), (np.ones((4, 3)), np.empty((4, 1)))], ids=['(1,)->()', '(2,)->(1,)', '(4, 3)->(4, 1)'])
def test_out_broadcast_errors(self, arr, out): (source)

Undocumented

def test_out_broadcasts(self): (source)

Undocumented

def test_output_argument(self): (source)

Undocumented

@pytest.mark.parametrize('casting', ['unsafe', 'same_kind', 'safe'])
def test_partial_signature_mismatch(self, casting): (source)

Undocumented

def test_partial_signature_mismatch_with_cache(self): (source)

Undocumented

def test_pickle(self): (source)

Undocumented

def test_pickle_name_is_qualname(self): (source)

Undocumented

def test_pickle_withstring(self): (source)

Undocumented

def test_reduce_arguments(self): (source)

Undocumented

def test_reduce_noncontig_output(self): (source)

Undocumented

def test_reduce_output_does_not_broadcast_input(self): (source)

Undocumented

def test_reduce_output_subclass_ok(self): (source)

Undocumented

@pytest.mark.parametrize('out_shape', [(), (1), (3), (1, 1), (1, 3), (4, 3)])
@pytest.mark.parametrize('keepdims', [True, False])
@pytest.mark.parametrize('f_reduce', [np.add.reduce, np.minimum.reduce])
def test_reduce_wrong_dimension_output(self, f_reduce, keepdims, out_shape): (source)

Undocumented

def test_reduce_zero_axis(self): (source)

Undocumented

@pytest.mark.parametrize('with_cast', [True, False])
def test_reduceat_and_accumulate_out_shape_mismatch(self, with_cast): (source)

Undocumented

def test_reduceat_shifting_sum(self): (source)

Undocumented

def test_reducelike_byteorder_resolution(self): (source)

Undocumented

def test_reducelike_out_promotes(self): (source)

Undocumented

def test_reducelike_output_needs_identical_cast(self): (source)

Undocumented

def test_reduction_where_initial_needed(self): (source)

Undocumented

@pytest.mark.parametrize('axis', (0, 1, None))
@pytest.mark.parametrize('where', (np.array([False, True, True]), np.array([[True], [False], [True]]), np.array([[True, False, False], [False, True, False], [False, True, True]])))
def test_reduction_with_where(self, axis, where): (source)

Undocumented

@pytest.mark.parametrize(('axis', 'where'), ((0, np.array([True, False, True])), (1, [True, True, False]), (None, True)))
@pytest.mark.parametrize('initial', (-np.inf, 5.0))
def test_reduction_with_where_and_initial(self, axis, where, initial): (source)

Undocumented

def test_safe_casting(self): (source)

Undocumented

def test_scalar_equal(self): (source)

Undocumented

def test_scalar_reduction(self): (source)

Undocumented

def test_signature0(self): (source)

Undocumented

def test_signature1(self): (source)

Undocumented

def test_signature10(self): (source)

Undocumented

def test_signature2(self): (source)

Undocumented

def test_signature3(self): (source)

Undocumented

def test_signature4(self): (source)

Undocumented

def test_signature5(self): (source)

Undocumented

def test_signature6(self): (source)

Undocumented

def test_signature7(self): (source)

Undocumented

def test_signature8(self): (source)

Undocumented

def test_signature9(self): (source)

Undocumented

def test_signature_all_None(self): (source)

Undocumented

@pytest.mark.parametrize('get_kwarg', [param((lambda x: dict(dtype=x)), id='dtype'), param((lambda x: dict(signature=(x, None, None))), id='signature')])
def test_signature_dtype_instances_allowed(self, get_kwarg): (source)

Undocumented

def test_signature_dtype_type(self): (source)

Undocumented

def test_signature_errors(self): (source)

Undocumented

def test_signature_failure_extra_parenthesis(self): (source)

Undocumented

def test_signature_failure_mismatching_parenthesis(self): (source)

Undocumented

def test_signature_failure_signature_missing_input_arg(self): (source)

Undocumented

def test_signature_failure_signature_missing_output_arg(self): (source)

Undocumented

def test_struct_ufunc(self): (source)

Undocumented

def test_structured_equal(self): (source)

Undocumented

@pytest.mark.skipif(IS_WASM, reason='fp errors don\'t work in wasm')
def test_sum(self): (source)

Undocumented

def test_sum_complex(self): (source)

Undocumented

def test_sum_initial(self): (source)

Undocumented

def test_sum_stability(self): (source)

Undocumented

def test_sum_where(self): (source)

Undocumented

def test_true_divide(self): (source)

Undocumented

def test_type_cast(self): (source)

Undocumented

def test_ufunc_custom_out(self): (source)

Undocumented

def test_use_output_signature_for_all_arguments(self): (source)

Undocumented

def test_where_param(self): (source)

Undocumented

def test_where_param_alloc(self): (source)

Undocumented

def test_where_param_buffer_output(self): (source)

Undocumented

def test_where_with_broadcasting(self): (source)

Undocumented

def test_zerosize_reduction(self): (source)

Undocumented

can_ignore: int = (source)

Undocumented

size_inferred: int = (source)

Undocumented