コード例 #1
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
        def __setitem__(self, i, value):
            if isinstance(i, (int, long)):
                self.array.set(i, value)

            elif isinstance(i, slice):
                if isinstance(value, ObjectArray):
                    raise Exception
                elif isinstance(value, ndarray):
                    what = value.array
                else:
                    what = value

                try:
                    Numpy.setslice(what, self.array, i.start or 0, i.stop or len(self), i.step or 1)
                except java.lang.IllegalArgumentException:
                    raise ValueError("Could not broadcast arrays of different shapes")

            elif isinstance(i, ndarray):
                if isinstance(value, ObjectArray):
                    raise Exception
                elif isinstance(value, ndarray):
                    what = value.array
                else:
                    what = value

                try:
                    Numpy.setfancy(what, self.array, i.array)
                except java.lang.IllegalArgumentException:
                    raise ValueError("Could not broadcast arrays of different shapes")
                except java.lang.IndexOutOfBoundsException:
                    raise IndexError("Index out of bounds")

            else:
                raise NotImplementedError
コード例 #2
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def ones(shape, dtype=float, order="C"):
     if isinstance(shape, int):
         if dtype is bool:
             return ndarray(Numpy.onesBoolean(shape))
         elif dtype is float:
             return ndarray(Numpy.onesDouble(shape))
         elif dtype is int:
             return ndarray(Numpy.onesInteger(shape))
         elif dtype is object:
             return ObjectArray([1] * shape)
         else:
             raise NotImplementedError
     else:
         raise NotImplementedError
コード例 #3
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def ones(shape, dtype=float, order="C"):
     if isinstance(shape, int):
         if dtype is bool:
             return ndarray(Numpy.onesBoolean(shape))
         elif dtype is float:
             return ndarray(Numpy.onesDouble(shape))
         elif dtype is int:
             return ndarray(Numpy.onesInteger(shape))
         elif dtype is object:
             return ObjectArray([1] * shape)
         else:
             raise NotImplementedError
     else:
         raise NotImplementedError
コード例 #4
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
        def __getitem__(self, i):
            if isinstance(i, (int, long)):
                return self.array.get(i)

            elif isinstance(i, slice):
                return ndarray(Numpy.getslice(self.array, i.start or 0, i.stop or len(self), i.step or 1))

            elif isinstance(i, ndarray):
                try:
                    return ndarray(Numpy.getfancy(self.array, i.array));
                except java.lang.IndexOutOfBoundsException:
                    raise IndexError("Index out of bounds")

            else:
                raise NotImplementedError
コード例 #5
0
ファイル: numpy.py プロジェクト: soedjais/augustus
        def __getitem__(self, i):
            if isinstance(i, (int, long)):
                return self.array.get(i)

            elif isinstance(i, slice):
                return ndarray(
                    Numpy.getslice(self.array, i.start or 0, i.stop
                                   or len(self), i.step or 1))

            elif isinstance(i, ndarray):
                try:
                    return ndarray(Numpy.getfancy(self.array, i.array))
                except java.lang.IndexOutOfBoundsException:
                    raise IndexError("Index out of bounds")

            else:
                raise NotImplementedError
コード例 #6
0
ファイル: numpy.py プロジェクト: soedjais/augustus
        def __setitem__(self, i, value):
            if isinstance(i, (int, long)):
                self.array.set(i, value)

            elif isinstance(i, slice):
                if isinstance(value, ObjectArray):
                    raise Exception
                elif isinstance(value, ndarray):
                    what = value.array
                else:
                    what = value

                try:
                    Numpy.setslice(what, self.array, i.start or 0, i.stop
                                   or len(self), i.step or 1)
                except java.lang.IllegalArgumentException:
                    raise ValueError(
                        "Could not broadcast arrays of different shapes")

            elif isinstance(i, ndarray):
                if isinstance(value, ObjectArray):
                    raise Exception
                elif isinstance(value, ndarray):
                    what = value.array
                else:
                    what = value

                try:
                    Numpy.setfancy(what, self.array, i.array)
                except java.lang.IllegalArgumentException:
                    raise ValueError(
                        "Could not broadcast arrays of different shapes")
                except java.lang.IndexOutOfBoundsException:
                    raise IndexError("Index out of bounds")

            else:
                raise NotImplementedError
コード例 #7
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def count_nonzero(x): return Numpy.count_nonzero(x.array)
 def mean(x): return Numpy.mean(x.array)
コード例 #8
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def copy(x): return Numpy.copy(x.array)
 def count_nonzero(x): return Numpy.count_nonzero(x.array)
コード例 #9
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def __init__(self, pythonList):
     self.pythonList = pythonList
     self.indexArray = ndarray(Numpy.indexArray(len(pythonList)))
コード例 #10
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
        def __setitem__(self, i, value):
            if isinstance(i, (int, long)):
                self.pythonList[i] = value

            elif isinstance(i, slice):
                if isinstance(value, ndarray):
                    p = self.pythonList
                    if isinstance(value, ObjectArray):
                        g = value.pythonList.__getitem__
                    else:
                        g = value.array.get
                    for index in xrange(i.start or 0, i.stop or len(self), i.step or 1):
                        p[index] = g(index)

                else:
                    p = self.pythonList
                    for index in xrange(i.start or 0, i.stop or len(self), i.step or 1):
                        p[index] = value

            elif isinstance(i, ndarray):
                if isinstance(i.array, ArrayBoolean1d):
                    if len(i) != len(self):
                        raise ValueError("Could not broadcast arrays of different shapes")

                    if isinstance(value, ndarray):
                        if Numpy.count_nonzero(i.array) != len(value):
                            raise ValueError("Could not broadcast arrays of different shapes")

                        j = 0
                        p = self.pythonList
                        if isinstance(value, ObjectArray):
                            g = value.pythonList.__getitem__
                        else:
                            g = value.array.get
                        for ii in xrange(len(self)):
                            if i.array.get(ii):
                                p[ii] = g(j)
                                j += 1

                    else:
                        p = self.pythonList
                        for ii in xrange(len(self)):
                            if i.array.get(ii):
                                p[ii] = value

                elif isinstance(i.array, ArrayInteger1d):
                    if isinstance(value, ndarray):
                        if len(i) != len(value):
                            raise ValueError("Could not broadcast arrays of different shapes")

                        l = len(self)
                        p = self.pythonList
                        for ii in xrange(len(i)):
                            index = i.array.get(ii)
                            if index < 0:
                                index = l + index
                            p[index] = value[ii]

                    else:
                        l = len(self)
                        p = self.pythonList
                        for ii in xrange(len(i)):
                            index = i.array.get(ii)
                            if index < 0:
                                index = l + index
                            p[index] = value

                else:
                    raise Exception
コード例 #11
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def count_nonzero(x):
     return Numpy.count_nonzero(x.array)
コード例 #12
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
    def sum(x): return Numpy.sum(x.array)

except ImportError:
コード例 #13
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def nanmin(x): return Numpy.nanmin(x.array)
 def std(x, ddof=0): return Numpy.std(x.array, ddof)
コード例 #14
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def sum(x):
     return Numpy.sum(x.array)
コード例 #15
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def std(x, ddof=0):
     return Numpy.std(x.array, ddof)
コード例 #16
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def nanmin(x):
     return Numpy.nanmin(x.array)
コード例 #17
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def nanmax(x):
     return Numpy.nanmax(x.array)
コード例 #18
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def mean(x):
     return Numpy.mean(x.array)
コード例 #19
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def copy(self):
     return Numpy.copy(self.array)
コード例 #20
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def mean(x): return Numpy.mean(x.array)
 def nanmax(x): return Numpy.nanmax(x.array)
コード例 #21
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def nanmax(x): return Numpy.nanmax(x.array)
 def nanmin(x): return Numpy.nanmin(x.array)
コード例 #22
0
ファイル: numpy.py プロジェクト: soedjais/augustus
        def __setitem__(self, i, value):
            if isinstance(i, (int, long)):
                self.pythonList[i] = value

            elif isinstance(i, slice):
                if isinstance(value, ndarray):
                    p = self.pythonList
                    if isinstance(value, ObjectArray):
                        g = value.pythonList.__getitem__
                    else:
                        g = value.array.get
                    for index in xrange(i.start or 0, i.stop or len(self),
                                        i.step or 1):
                        p[index] = g(index)

                else:
                    p = self.pythonList
                    for index in xrange(i.start or 0, i.stop or len(self),
                                        i.step or 1):
                        p[index] = value

            elif isinstance(i, ndarray):
                if isinstance(i.array, ArrayBoolean1d):
                    if len(i) != len(self):
                        raise ValueError(
                            "Could not broadcast arrays of different shapes")

                    if isinstance(value, ndarray):
                        if Numpy.count_nonzero(i.array) != len(value):
                            raise ValueError(
                                "Could not broadcast arrays of different shapes"
                            )

                        j = 0
                        p = self.pythonList
                        if isinstance(value, ObjectArray):
                            g = value.pythonList.__getitem__
                        else:
                            g = value.array.get
                        for ii in xrange(len(self)):
                            if i.array.get(ii):
                                p[ii] = g(j)
                                j += 1

                    else:
                        p = self.pythonList
                        for ii in xrange(len(self)):
                            if i.array.get(ii):
                                p[ii] = value

                elif isinstance(i.array, ArrayInteger1d):
                    if isinstance(value, ndarray):
                        if len(i) != len(value):
                            raise ValueError(
                                "Could not broadcast arrays of different shapes"
                            )

                        l = len(self)
                        p = self.pythonList
                        for ii in xrange(len(i)):
                            index = i.array.get(ii)
                            if index < 0:
                                index = l + index
                            p[index] = value[ii]

                    else:
                        l = len(self)
                        p = self.pythonList
                        for ii in xrange(len(i)):
                            index = i.array.get(ii)
                            if index < 0:
                                index = l + index
                            p[index] = value

                else:
                    raise Exception
コード例 #23
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def std(x, ddof=0): return Numpy.std(x.array, ddof)
 def sum(x): return Numpy.sum(x.array)
コード例 #24
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def __init__(self, pythonList):
     self.pythonList = pythonList
     self.indexArray = ndarray(Numpy.indexArray(len(pythonList)))
コード例 #25
0
ファイル: numpy.py プロジェクト: Huskyeder/augustus
 def copy(self):
     return Numpy.copy(self.array)
コード例 #26
0
ファイル: numpy.py プロジェクト: soedjais/augustus
 def copy(x):
     return Numpy.copy(x.array)