test_ufunc

Module Contents

class TestUfunc

Bases:TestCase

test_pickle(self)
test_pickle_withstring(self)
test_reduceat_shifting_sum(self)
test_generic_loops(self)

Test generic loops.

The loops to be tested are:

PyUFunc_ff_f_As_dd_d PyUFunc_ff_f PyUFunc_dd_d PyUFunc_gg_g PyUFunc_FF_F_As_DD_D PyUFunc_DD_D PyUFunc_FF_F PyUFunc_GG_G PyUFunc_OO_O PyUFunc_OO_O_method PyUFunc_f_f_As_d_d PyUFunc_d_d PyUFunc_f_f PyUFunc_g_g PyUFunc_F_F_As_D_D PyUFunc_F_F PyUFunc_D_D PyUFunc_G_G PyUFunc_O_O PyUFunc_O_O_method PyUFunc_On_Om

Where:

f – float d – double g – long double F – complex float D – complex double G – complex long double O – python object

It is difficult to assure that each of these loops is entered from the Python level as the special cased loops are a moving target and the corresponding types are architecture dependent. We probably need to define C level testing ufuncs to get at them. For the time being, I’ve just looked at the signatures registered in the build directory to find relevant functions.

Fixme, currently untested:

PyUFunc_ff_f_As_dd_d PyUFunc_FF_F_As_DD_D PyUFunc_f_f_As_d_d PyUFunc_F_F_As_D_D PyUFunc_On_Om
test_all_ufunc(self)

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

test_signature(self)
test_get_signature(self)
test_forced_sig(self)
test_sum_stability(self)
test_sum(self)
test_sum_complex(self)
test_inner1d(self)
test_broadcast(self)
test_type_cast(self)
test_endian(self)
test_incontiguous_array(self)
test_output_argument(self)
test_innerwt(self)
test_innerwt_empty(self)

Test generalized ufunc with zero-sized operands

test_matrix_multiply(self)
compare_matrix_multiply_results(self, tp)
test_object_logical(self)
test_object_array_reduction(self)
test_object_scalar_multiply(self)
test_zerosize_reduction(self)
test_axis_out_of_bounds(self)
test_scalar_reduction(self)
test_casting_out_param(self)
test_where_param(self)
test_where_param_buffer_output(self)
check_identityless_reduction(self, a)
test_identityless_reduction_corder(self)
test_identityless_reduction_forder(self)
test_identityless_reduction_otherorder(self)
test_identityless_reduction_noncontig(self)
test_identityless_reduction_noncontig_unaligned(self)
test_identityless_reduction_nonreorderable(self)
test_reduce_zero_axis(self)
test_safe_casting(self)
test_ufunc_custom_out(self)
test_operand_flags(self)
test_struct_ufunc(self)
test_custom_ufunc(self)
test_custom_array_like(self)
test_inplace_fancy_indexing(self)
test_reduce_arguments(self)