Ignore:
Timestamp:
Jun 30, 2009, 2:07:41 PM (15 years ago)
Author:
ole
Message:

Merged numpy branch back into the trunk.

In ~/sandpit/anuga/anuga_core/source
svn merge -r 6246:HEAD ../../branches/numpy .

In ~/sandpit/anuga/anuga_validation
svn merge -r 6417:HEAD ../branches/numpy_anuga_validation .

In ~/sandpit/anuga/misc
svn merge -r 6809:HEAD ../branches/numpy_misc .

For all merges, I used numpy version where conflicts existed

The suites test_all.py (in source/anuga) and validate_all.py passed using Python2.5 with numpy on my Ubuntu Linux box.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/where_close.py

    r5681 r7276  
    6262    y are "equal", and 0 otherwise.  If x or y are floating point,
    6363    "equal" means where abs(x-y) <= atol + rtol * abs(y).  This is
    64     essentially the same algorithm used in the Numeric function
     64    essentially the same algorithm used in the numeric function
    6565    allclose.  If x and y are integer, "equal" means strict equality. 
    6666    Shape and size of output is the same as x and y; if one is an
    6767    array and the other is scalar, shape and size of the output is the
    68     same as the array.  Output is a Numeric array, unless both inputs
     68    same as the array.  Output is a numeric array, unless both inputs
    6969    are scalar in which the output is a Python integer scalar.
    7070
    7171    Positional Input Arguments:
    72     * x:  Scalar or Numeric array, Python list/tuple of any size and
     72    * x:  Scalar or numeric array, Python list/tuple of any size and
    7373      shape.  Floating or integer type.
    74     * y:  Scalar or Numeric array, Python list/tuple of any size and
     74    * y:  Scalar or numeric array, Python list/tuple of any size and
    7575      shape.  Floating or integer type.
    7676
     
    8484
    8585    Examples:
    86     >>> import Numeric as N
     86    >>> import numpy as N
    8787    >>> from where_close import where_close
    8888    >>> x = [20.,  -32., -1., 2.            , 5., 29.]
     
    9898    ['1', '0', '0', '1', '0']
    9999    """
    100     import Numeric as N
     100    import numpy as N
    101101    abs = N.absolute
    102102
    103103
    104     #- Make sure input is Numeric type:
     104    #- Make sure input is numeric type:
    105105
    106106    xN = N.array(x)
     
    111111    #  type returns an error:
    112112
    113     if (xN.typecode() in N.typecodes['Float']) or \
    114        (yN.typecode() in N.typecodes['Float']):
     113    if (xN.dtype.char in N.typecodes['Float']) or \
     114       (yN.dtype.char in N.typecodes['Float']):
    115115        return N.less_equal(abs(xN-yN), atol+rtol*abs(yN))
    116116
    117     elif (xN.typecode() in N.typecodes['Integer']) and \
    118          (yN.typecode() in N.typecodes['Integer']):
     117    elif (xN.dtype.char in N.typecodes['Integer']) and \
     118         (yN.dtype.char in N.typecodes['Integer']):
    119119        return N.equal(xN, yN)
    120120
     
    132132    """
    133133    >>> from where_close import where_close
    134     >>> import Numeric as N
     134    >>> import numpy as N
    135135    >>> x = [20.,  -32., -1., 2.            , 5., 29.]
    136136    >>> y = [20.1, -31., -1., 2.000000000001, 3., 28.99]
     
    144144    >>> ind.shape
    145145    (2, 3)
    146     >>> ind.typecode()
    147     'l'
     146    >>> ind.dtype.char
     147    '?'
    148148    >>> type(ind)
    149     <type 'array'>
     149    <type 'numpy.ndarray'>
    150150
    151151    >>> x = [20.,  -32., -1., 2.            , 5., 29.]
     
    179179    0
    180180    >>> type(ind)
    181     <type 'int'>
     181    <type 'numpy.bool_'>
    182182    >>> x = -33
    183183    >>> y = -33.
Note: See TracChangeset for help on using the changeset viewer.