From 2ee64fdacd5167472d868f8b155e5fbbfc9f00ce Mon Sep 17 00:00:00 2001 From: Tim Leslie Date: Thu, 23 Mar 2006 02:16:55 +0000 Subject: use docstring header, fix 'import *', remove duplicate definition of __float__, change first arg of method from 'a' to 'self' --- numpy/lib/UserArray.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'numpy/lib/UserArray.py') diff --git a/numpy/lib/UserArray.py b/numpy/lib/UserArray.py index 8745fa501..33d949a40 100644 --- a/numpy/lib/UserArray.py +++ b/numpy/lib/UserArray.py @@ -1,9 +1,13 @@ -# Standard container-class for easy backward compatibility -# with Numeric. -# Try to inherit from the ndarray instead of using this -# class as this is not complete. +""" +Standard container-class for easy backward compatibility with Numeric. +Try to inherit from the ndarray instead of using this class as this is not +complete. +""" -from numpy.core import * +from numpy.core import array, asarray, absolute, add, subtract, multiply, \ + divide, remainder, power, left_shift, right_shift, bitwise_and, \ + bitwise_or, bitwise_xor, invert, less, less_equal, not_equal, equal, \ + greater, greater_equal, shape, reshape, arange, sin, sqrt, transpose class UserArray(object): def __init__(self, data, dtype=None, copy=True): @@ -19,9 +23,6 @@ class UserArray(object): if t: return self.array.astype(t) return self.array - def __float__(self): - return float(self.array) - # Array as sequence def __len__(self): return len(self.array) @@ -144,9 +145,9 @@ class UserArray(object): def __invert__(self): return self._rc(invert(self.array)) - def _scalarfunc(a, func): - if len(a.shape) == 0: - return func(a[0]) + def _scalarfunc(self, func): + if len(self.shape) == 0: + return func(self[0]) else: raise TypeError, "only rank-0 arrays can be converted to Python scalars." @@ -196,8 +197,6 @@ class UserArray(object): # Test of class UserArray ############################################################# if __name__ == '__main__': - import numpy - temp=reshape(arange(10000),(100,100)) ua=UserArray(temp) -- cgit v1.2.1