~jtaylor/ubuntu/precise/python-numpy/multiarch-fix-818867

« back to all changes in this revision

Viewing changes to numpy/oldnumeric/arrayfns.py

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik, Riku Voipio, Tiziano Zito, Carlos Galisteo, Ondrej Certik
  • Date: 2008-07-08 15:08:16 UTC
  • mfrom: (0.1.21 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080708150816-ekf992jcp2k1eua3
Tags: 1:1.1.0-3
[ Riku Voipio ]
* debian/control: atlas is not available on armel, and after a quick look
  neither on alpha. I'd also suggest dropping
  libatlas-sse-dev|libatlas-sse2-dev|libatlas-3dnow-dev alternative combo
  away, these are potentially dangerous on buildd's. Ondrej: dropped.
  (Closes: #489568)

[ Tiziano Zito ]
* patch: build _dotblas.c when ATLAS is not installed, build-conflict with
  atlas, build-depend on blas+lapack only, as it used to be (Closes: #489726)

[ Carlos Galisteo ]
* debian/control
  - Added Homepage field.

[ Ondrej Certik ]
* Checked the package on i386 and amd64, both with and without atlas, all
  tests run and the numpy package is faster if atlas is around. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Backward compatible with arrayfns from Numeric
 
2
"""
 
3
 
 
4
__all__ = ['array_set', 'construct3', 'digitize', 'error', 'find_mask', 'histogram', 'index_sort',
 
5
           'interp', 'nz', 'reverse', 'span', 'to_corners', 'zmin_zmax']
 
6
 
 
7
import numpy as nx
 
8
from numpy import asarray
 
9
 
 
10
class error(Exception):
 
11
    pass
 
12
 
 
13
def array_set(vals1, indices, vals2):
 
14
    indices = asarray(indices)
 
15
    if indices.ndim != 1:
 
16
        raise ValueError, "index array must be 1-d"
 
17
    if not isinstance(vals1, ndarray):
 
18
        raise TypeError, "vals1 must be an ndarray"
 
19
    vals1 = asarray(vals1)
 
20
    vals2 = asarray(vals2)
 
21
    if vals1.ndim != vals2.ndim or vals1.ndim < 1:
 
22
        raise error, "vals1 and vals2 must have same number of dimensions (>=1)"
 
23
    vals1[indices] = vals2
 
24
 
 
25
from numpy import digitize
 
26
from numpy import bincount as histogram
 
27
 
 
28
def index_sort(arr):
 
29
    return asarray(arr).argsort(kind='heap')
 
30
 
 
31
def interp(y, x, z, typ=None):
 
32
    """y(z) interpolated by treating y(x) as piecewise function
 
33
    """
 
34
    res = numpy.interp(z, x, y)
 
35
    if typ is None or typ == 'd':
 
36
        return res
 
37
    if typ == 'f':
 
38
        return res.astype('f')
 
39
 
 
40
    raise error, "incompatible typecode"
 
41
 
 
42
def nz(x):
 
43
    x = asarray(x,dtype=nx.ubyte)
 
44
    if x.ndim != 1:
 
45
        raise TypeError, "intput must have 1 dimension."
 
46
    indxs = nx.flatnonzero(x != 0)
 
47
    return indxs[-1].item()+1
 
48
 
 
49
def reverse(x, n):
 
50
    x = asarray(x,dtype='d')
 
51
    if x.ndim != 2:
 
52
        raise ValueError, "input must be 2-d"
 
53
    y = nx.empty_like(x)
 
54
    if n == 0:
 
55
        y[...] = x[::-1,:]
 
56
    elif n == 1:
 
57
        y[...] = x[:,::-1]
 
58
    return y
 
59
 
 
60
def span(lo, hi, num, d2=0):
 
61
    x = linspace(lo, hi, num)
 
62
    if d2 <= 0:
 
63
        return x
 
64
    else:
 
65
        ret = empty((d2,num),x.dtype)
 
66
        ret[...] = x
 
67
        return ret
 
68
 
 
69
def zmin_zmax(z, ireg):
 
70
    z = asarray(z, dtype=float)
 
71
    ireg = asarray(ireg, dtype=int)
 
72
    if z.shape != ireg.shape or z.ndim != 2:
 
73
        raise ValueError, "z and ireg must be the same shape and 2-d"
 
74
    ix, iy = nx.nonzero(ireg)
 
75
    # Now, add more indices
 
76
    x1m = ix - 1
 
77
    y1m = iy-1
 
78
    i1 = x1m>=0
 
79
    i2 = y1m>=0
 
80
    i3 = i1 & i2
 
81
    nix = nx.r_[ix, x1m[i1], x1m[i1], ix[i2] ]
 
82
    niy = nx.r_[iy, iy[i1],  y1m[i3], y1m[i2]]
 
83
    # remove any negative indices
 
84
    zres = z[nix,niy]
 
85
    return zres.min().item(), zres.max().item()
 
86
 
 
87
 
 
88
def find_mask(fs, node_edges):
 
89
    raise NotImplementedError
 
90
 
 
91
def to_corners(arr, nv, nvsum):
 
92
    raise NotImplementedError
 
93
 
 
94
 
 
95
def construct3(mask, itype):
 
96
    raise NotImplementedError