Utility functions

set_numeric_ops (<opl>=funcl, <op2>=func2, ...)

This function can be used to alter the operations used for internal array calculations and array special methods. Replaceable operations (and possible entries for <opN>) are add, subtract, multiply, divide, remainder, power, sqrt, negative, absolute, invert, left_shift, rightjshift, bitwise_and, bitwise_or, less, less_equal, equal, not_equal, greater, greater_equal, floor_divide, true_divide, logicaLor, logicaLand, floor, ceil, maximum, and minimum. The example code below changes, then restores, the old Numeric behavior of remainder (which was changed because it was not consistent with Python).

>>>

a = array([-3.,-2,-1,0,1,2,3])

>>>

print a

% -2.1

[-0

. 9 -2. -

1. 0. -1.1 -0.1 -1.2]

>>>

oldops =

: set_numeric-ops (remainder:

>>>

print a

% -2.1

[-0

. 9 -2. -

1. 0. 1. 2. 0.9]

>>>

newops =

^ set_numeric-ops (**oldops)

>>>

print a

% -2.1

[-0

. 9 -2. -

1. 0. -1.1 -0.1 -1.2]

>>>

print 3

% -2.1 # comparison

get_include ()

Return the directory that contains the numpy include files. The numpy.distutils automatically includes this directory in building extensions.

get_numarray_include (type=None)

Return the directory that contains the numarray compatible C-API include files. If type is not None, then return a list containing both the numarray compatible

C-API include files and the numpy include files. The latter form is only needed when building an extension without the use of numpy.distutils.

deprecate (func, oldname, newname)

Return a deprecated function named 'oldname' that has been replaced by 'new-name'. This new deprecated function issues a warning before calling the old function. The name and docs of the function are also updated to be oldname instead of the name that func has. Example usage. If you want to deprecate the function named 'old' in favor of a new function named 'new' which has the same calling conention then this could be done with the assignment old = deprecate(new, 'old', 'new')

0 0

Post a comment