[SciPy-user] sequence emulation -/-> array access?

Dan Christensen jdc at uwo.ca
Sat Dec 17 18:18:46 EST 2005


Alan G Isaac <aisaac at american.edu> writes:

> I want to be able to do
> x = simple([1,2,3])
> y = scipy.array(x)
> One reason: I don't want to test for what
> kind of object I am passing to scipy.array,
> whether it has the get_data attribute, etc.
>
> So my question is:
> what is a minimal set of attributes to allow
> this to work.  I have found that sequence emulation (see:
> http://docs.python.org/ref/sequence-types.html )
> is not enough.

I don't know the answer to your question, but I have a related
question.  I've read that subclasses Numeric and numarray is
non-trivial.  Is this any easier with scipy core?

In more detail, I'd like to override + and * on arrays, but allow them
to be used in other ways as standard arrays, e.g. innerproduct(a,b)
should do the usual thing.

Dan




More information about the SciPy-User mailing list